diff options
| author | Andreas Rheinhardt <[email protected]> | 2020-03-21 03:57:32 +0100 |
|---|---|---|
| committer | Andreas Rheinhardt <[email protected]> | 2020-07-02 10:15:06 +0200 |
| commit | 8714b82970897f30866d44fc5c1224cd0ff2634f (patch) | |
| tree | 8982004305846b85035cc0d838320358f380c9be | |
| parent | 27c4e7d99c009977a622743afdef40fdeefcc98b (diff) | |
avformat/bethsoftvid: Fix potential memleak upon reallocation failure
The classical ptr = av_realloc(ptr, size), just with av_fast_realloc().
Signed-off-by: Andreas Rheinhardt <[email protected]>
Reviewed-by: Paul B Mahol <[email protected]>
Signed-off-by: Michael Niedermayer <[email protected]>
(cherry picked from commit 5acef1206144554a48f699b421e8d739e752d8ab)
Signed-off-by: Andreas Rheinhardt <[email protected]>
| -rw-r--r-- | libavformat/bethsoftvid.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c index f516806d91..752e05236d 100644 --- a/libavformat/bethsoftvid.c +++ b/libavformat/bethsoftvid.c @@ -146,9 +146,13 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt, } do{ - vidbuf_start = av_fast_realloc(vidbuf_start, &vidbuf_capacity, vidbuf_nbytes + BUFFER_PADDING_SIZE); - if(!vidbuf_start) - return AVERROR(ENOMEM); + uint8_t *tmp = av_fast_realloc(vidbuf_start, &vidbuf_capacity, + vidbuf_nbytes + BUFFER_PADDING_SIZE); + if (!tmp) { + ret = AVERROR(ENOMEM); + goto fail; + } + vidbuf_start = tmp; code = avio_r8(pb); vidbuf_start[vidbuf_nbytes++] = code; |
