summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo_enc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/mpegvideo_enc.c')
-rw-r--r--libavcodec/mpegvideo_enc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 55550d555f..af5b85fee3 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2845,6 +2845,11 @@ int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t s
uint8_t *new_buffer = NULL;
int new_buffer_size = 0;
+ if ((s->avctx->internal->byte_buffer_size + size_increase) >= INT_MAX/8) {
+ av_log(s->avctx, AV_LOG_ERROR, "Cannot reallocate putbit buffer\n");
+ return AVERROR(ENOMEM);
+ }
+
av_fast_padded_malloc(&new_buffer, &new_buffer_size,
s->avctx->internal->byte_buffer_size + size_increase);
if (!new_buffer)