Fixes: memleak Fixes: 17615/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA2_fuzzer-5681306024804352
Unified · Split
| @@ -1793,6 +1793,12 @@ static int xma_decode_packet(AVCodecContext *avctx, void *data, · 1792 unmodified lines | ||
| 1793 | 1793 | AVFrame *frame = data; |
| 1794 | 1794 | int i, ret, offset = INT_MAX; |
| 1795 | 1795 | |
| 1796 | + if (!s->frames[s->current_stream]->data[0]) { | |
| 1797 | + s->frames[s->current_stream]->nb_samples = 512; | |
| 1798 | + if ((ret = ff_get_buffer(avctx, s->frames[s->current_stream], 0)) < 0) { | |
| 1799 | + return ret; | |
| 1800 | + } | |
| 1801 | + } | |
| 1796 | 1802 | /* decode current stream packet */ |
| 1797 | 1803 | ret = decode_packet(avctx, &s->xma[s->current_stream], s->frames[s->current_stream], |
| 1798 | 1804 | &got_stream_frame_ptr, avpkt); |
| @@ -1920,10 +1926,6 @@ static av_cold int xma_decode_init(AVCodecContext *avctx) · 121 unmodified lines | ||
| 1920 | 1926 | s->frames[i] = av_frame_alloc(); |
| 1921 | 1927 | if (!s->frames[i]) |
| 1922 | 1928 | return AVERROR(ENOMEM); |
| 1923 | − s->frames[i]->nb_samples = 512; | |
| 1924 | − if ((ret = ff_get_buffer(avctx, s->frames[i], 0)) < 0) { | |
| 1925 | − return AVERROR(ENOMEM); | |
| 1926 | − } | |
| 1927 | 1929 | |
| 1928 | 1930 | s->start_channel[i] = start_channels; |
| 1929 | 1931 | start_channels += s->xma[i].nb_channels; |