diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-09-11 10:54:41 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-09-11 11:23:40 +0200 |
commit | cbe47b1e8452e37fda592941e7d3f3bb5920c201 (patch) | |
tree | 9ea8b6418c4d89e27c98314d41974163b5dbafe8 /libavformat/utils.c | |
parent | 64b6279d1414378214a58a55f0066fbc95256c9b (diff) | |
parent | f369b9356c4606cd4d713d60f7db5de119d901fa (diff) | |
download | ffmpeg-cbe47b1e8452e37fda592941e7d3f3bb5920c201.tar.gz |
Merge commit 'f369b9356c4606cd4d713d60f7db5de119d901fa'
* commit 'f369b9356c4606cd4d713d60f7db5de119d901fa':
avformat: Use av_reallocp_array() where suitable
Conflicts:
libavformat/asfenc.c
libavformat/gxfenc.c
libavformat/mov.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 4d4b701baa..9c21ae0fe1 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3296,14 +3296,11 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c) { AVStream *st; int i; - AVStream **streams; - if (s->nb_streams >= INT_MAX/sizeof(*streams)) + if (av_reallocp_array(&s->streams, s->nb_streams + 1, sizeof(*s->streams)) < 0) { + s->nb_streams = 0; return NULL; - streams = av_realloc(s->streams, (s->nb_streams + 1) * sizeof(*streams)); - if (!streams) - return NULL; - s->streams = streams; + } st = av_mallocz(sizeof(AVStream)); if (!st) @@ -3407,7 +3404,6 @@ void ff_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int i { int i, j; AVProgram *program=NULL; - void *tmp; if (idx >= ac->nb_streams) { av_log(ac, AV_LOG_ERROR, "stream index %d is not valid\n", idx); @@ -3422,10 +3418,12 @@ void ff_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int i if(program->stream_index[j] == idx) return; - tmp = av_realloc(program->stream_index, sizeof(unsigned int)*(program->nb_stream_indexes+1)); - if(!tmp) + if (av_reallocp_array(&program->stream_index, + program->nb_stream_indexes + 1, + sizeof(*program->stream_index)) < 0) { + program->nb_stream_indexes = 0; return; - program->stream_index = tmp; + } program->stream_index[program->nb_stream_indexes++] = idx; return; } |