diff options
author | Kristian Amlie <kristian@gridmedia.com> | 2007-03-02 13:23:06 +0000 |
---|---|---|
committer | Guillaume Poirier <gpoirier@mplayerhq.hu> | 2007-03-02 13:23:06 +0000 |
commit | 0cbff0275b0cff4021e7026ba6060594225fcab5 (patch) | |
tree | 5b1d298959934c4c315e6dfedf05844667f1e4bd | |
parent | 57d4d6e733d82a6bfc9306a1036767c8f7b1eb40 (diff) | |
download | ffmpeg-0cbff0275b0cff4021e7026ba6060594225fcab5.tar.gz |
replace the auto array "duration_error" with a malloced array.
prevents stack overflow on some plateforms
patch by Kristian Amlie %kristian A gridmedia P com %
Original thread:
Date: Mar 1, 2007 11:29 PM
Subject: [Ffmpeg-devel] Stack overflow patch
Originally committed as revision 8194 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/utils.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 9e40668014..b71864d1c7 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1814,9 +1814,12 @@ int av_find_stream_info(AVFormatContext *ic) AVPacketList *pktl=NULL, **ppktl; int64_t last_dts[MAX_STREAMS]; int duration_count[MAX_STREAMS]={0}; - double duration_error[MAX_STREAMS][MAX_STD_TIMEBASES]={{0}}; //FIXME malloc()? + double (*duration_error)[MAX_STD_TIMEBASES]; offset_t old_offset = url_ftell(&ic->pb); + duration_error = av_mallocz(MAX_STREAMS * sizeof(*duration_error)); + if (!duration_error) return AVERROR_NOMEM; + for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; if(st->codec->codec_type == CODEC_TYPE_VIDEO){ @@ -1927,7 +1930,7 @@ int av_find_stream_info(AVFormatContext *ic) // if(st->codec->codec_type == CODEC_TYPE_VIDEO) // av_log(NULL, AV_LOG_ERROR, "%f\n", dur); if(duration_count[index] < 2) - memset(duration_error, 0, sizeof(duration_error)); + memset(duration_error, 0, MAX_STREAMS * sizeof(*duration_error)); for(i=1; i<MAX_STD_TIMEBASES; i++){ int framerate= get_std_framerate(i); int ticks= lrintf(dur*framerate/(1001*12)); @@ -2050,6 +2053,9 @@ int av_find_stream_info(AVFormatContext *ic) } } #endif + + av_free(duration_error); + return ret; } |