diff options
author | Martin Storsjö <martin@martin.st> | 2013-03-13 14:13:46 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-03-13 20:41:25 +0200 |
commit | 4abf6fa095f8082499d5a24cdfb18eb4c1fec60e (patch) | |
tree | c44f67139b6adb7a4108e90a92bbd258b1850159 | |
parent | 7c147900b86c0f1cf030b7b844c670649c80c191 (diff) | |
download | ffmpeg-4abf6fa095f8082499d5a24cdfb18eb4c1fec60e.tar.gz |
ismindex: Check the return value of allocations
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r-- | tools/ismindex.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/ismindex.c b/tools/ismindex.c index 89b33e51ba..ad1f3a848c 100644 --- a/tools/ismindex.c +++ b/tools/ismindex.c @@ -300,10 +300,21 @@ static int handle_file(struct Tracks *tracks, const char *file, int split) tracks->duration = ctx->duration; for (i = 0; i < ctx->nb_streams; i++) { + struct Track **temp; AVStream *st = ctx->streams[i]; track = av_mallocz(sizeof(*track)); - tracks->tracks = av_realloc(tracks->tracks, - sizeof(*tracks->tracks) * (tracks->nb_tracks + 1)); + if (!track) { + err = AVERROR(ENOMEM); + goto fail; + } + temp = av_realloc(tracks->tracks, + sizeof(*tracks->tracks) * (tracks->nb_tracks + 1)); + if (!temp) { + av_free(track); + err = AVERROR(ENOMEM); + goto fail; + } + tracks->tracks = temp; tracks->tracks[tracks->nb_tracks] = track; track->name = file; |