summaryrefslogtreecommitdiff
path: root/libavformat/bethsoftvid.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-03-21 03:57:32 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2020-03-22 13:00:19 +0100
commit5acef1206144554a48f699b421e8d739e752d8ab (patch)
tree3f7c162f3a4bfae4995d9de580551a744ad74d95 /libavformat/bethsoftvid.c
parent6e14ddd1567e215957b754c2863ec715f74607b9 (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 <andreas.rheinhardt@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/bethsoftvid.c')
-rw-r--r--libavformat/bethsoftvid.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c
index 2d5171a01c..47a9a69330 100644
--- a/libavformat/bethsoftvid.c
+++ b/libavformat/bethsoftvid.c
@@ -147,9 +147,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;