History

avformat/mov: free streams earlier on error when parsing infe boxes

Fixes clusterfuzz-testcase-minimized-fuzzer_loadfile-5365661771825152.

James Almer committed 1 year ago

Commit 89187a81 parent 11a53331 file · +11 −11Browse files

Unified · Split

libavformat/mov.c+11−11
@@ -5406,7 +5406,7 @@ static int heif_add_stream(MOVContext *c, HEIFItem *item) · 5405 unmodified lines
54065406 return AVERROR(ENOMEM);
54075407 sc = av_mallocz(sizeof(MOVStreamContext));
54085408 if (!sc)
5409− return AVERROR(ENOMEM);
5409+ goto fail;
54105410
54115411 item->st = st;
54125412 st->id = item->item_id;
@@ -5430,27 +5430,33 @@ static int heif_add_stream(MOVContext *c, HEIFItem *item) · 17 unmodified lines
54305430 sc->stsc_count = 1;
54315431 sc->stsc_data = av_malloc_array(1, sizeof(*sc->stsc_data));
54325432 if (!sc->stsc_data)
5433− return AVERROR(ENOMEM);
5433+ goto fail;
54345434 sc->stsc_data[0].first = 1;
54355435 sc->stsc_data[0].count = 1;
54365436 sc->stsc_data[0].id = 1;
54375437 sc->chunk_offsets = av_malloc_array(1, sizeof(*sc->chunk_offsets));
54385438 if (!sc->chunk_offsets)
5439− return AVERROR(ENOMEM);
5439+ goto fail;
54405440 sc->chunk_count = 1;
54415441 sc->sample_sizes = av_malloc_array(1, sizeof(*sc->sample_sizes));
54425442 if (!sc->sample_sizes)
5443− return AVERROR(ENOMEM);
5443+ goto fail;
54445444 sc->sample_count = 1;
54455445 sc->stts_data = av_malloc_array(1, sizeof(*sc->stts_data));
54465446 if (!sc->stts_data)
5447− return AVERROR(ENOMEM);
5447+ goto fail;
54485448 sc->stts_count = 1;
54495449 sc->stts_data[0].count = 1;
54505450 // Not used for still images. But needed by mov_build_index.
54515451 sc->stts_data[0].duration = 0;
54525452
54535453 return 0;
5454+fail:
5455+ mov_free_stream_context(c->fc, st);
5456+ ff_remove_stream(c->fc, st);
5457+ item->st = NULL;
5458+
5459+ return AVERROR(ENOMEM);
54545460 }
54555461
54565462 static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
@@ -9001,12 +9007,6 @@ fail: · 3544 unmodified lines
90019007 continue;
90029008
90039009 av_freep(&item->name);
9004− if (!item->st)
9005− continue;
9006−
9007− mov_free_stream_context(c->fc, item->st);
9008− ff_remove_stream(c->fc, item->st);
9009− item->st = NULL;
90109010 }
90119011 return ret;
90129012 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t