[FFmpeg-devel] [PATCH 08/14] avcodec/ffv1dec: Check allocations for failure
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Sat Apr 24 14:14:40 EEST 2021
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/ffv1dec.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index 45bfe21be5..791dc073bf 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -259,9 +259,17 @@ static int decode_slice(AVCodecContext *c, void *arg)
if (fssrc->ac) {
pdst->state = av_malloc_array(CONTEXT_SIZE, psrc->context_count);
+ if (!pdst->state) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
memcpy(pdst->state, psrc->state, CONTEXT_SIZE * psrc->context_count);
} else {
pdst->vlc_state = av_malloc_array(sizeof(*pdst->vlc_state), psrc->context_count);
+ if (!pdst->vlc_state) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
memcpy(pdst->vlc_state, psrc->vlc_state, sizeof(*pdst->vlc_state) * psrc->context_count);
}
}
@@ -343,6 +351,10 @@ static int decode_slice(AVCodecContext *c, void *arg)
ff_thread_report_progress(&f->picture, si, 0);
return 0;
+fail:
+ fs->slice_damaged = 1;
+ ff_thread_report_progress(&f->picture, si, 0);
+ return ret;
}
static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale)
--
2.27.0
More information about the ffmpeg-devel
mailing list