History

avcodec/vc1dec: Use av_fast_realloc() for slices

Fixes: Timeout Fixes: 57281/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-4594141064724480

Michael Niedermayer committed 3 years ago

Commit c2ed9051 parent 1942dbb1 file · +8 −3Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/vc1dec.c+8−3
@@ -836,6 +836,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 835 unmodified lines
836 const uint8_t *rawbuf;836 const uint8_t *rawbuf;
837 int raw_size;837 int raw_size;
838 } *slices = NULL, *tmp;838 } *slices = NULL, *tmp;
839 unsigned slices_allocated = 0;
839 840
840 v->second_field = 0;841 v->second_field = 0;
841 842
@@ -859,6 +860,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 17 unmodified lines
859 //for advanced profile we may need to parse and unescape data860 //for advanced profile we may need to parse and unescape data
860 if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {861 if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
861 int buf_size2 = 0;862 int buf_size2 = 0;
863 size_t next_allocated = 0;
862 buf2 = av_mallocz(buf_size + AV_INPUT_BUFFER_PADDING_SIZE);864 buf2 = av_mallocz(buf_size + AV_INPUT_BUFFER_PADDING_SIZE);
863 if (!buf2)865 if (!buf2)
864 return AVERROR(ENOMEM);866 return AVERROR(ENOMEM);
@@ -882,7 +884,8 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 17 unmodified lines
882 int buf_size3;884 int buf_size3;
883 if (avctx->hwaccel)885 if (avctx->hwaccel)
884 buf_start_second_field = start;886 buf_start_second_field = start;
885 tmp = av_realloc_array(slices, sizeof(*slices), n_slices+1);887 av_size_mult(sizeof(*slices), n_slices+1, &next_allocated);
888 tmp = next_allocated ? av_fast_realloc(slices, &slices_allocated, next_allocated) : NULL;
886 if (!tmp) {889 if (!tmp) {
887 ret = AVERROR(ENOMEM);890 ret = AVERROR(ENOMEM);
888 goto err;891 goto err;
@@ -911,7 +914,8 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 22 unmodified lines
911 break;914 break;
912 case VC1_CODE_SLICE: {915 case VC1_CODE_SLICE: {
913 int buf_size3;916 int buf_size3;
914 tmp = av_realloc_array(slices, sizeof(*slices), n_slices+1);917 av_size_mult(sizeof(*slices), n_slices+1, &next_allocated);
918 tmp = next_allocated ? av_fast_realloc(slices, &slices_allocated, next_allocated) : NULL;
915 if (!tmp) {919 if (!tmp) {
916 ret = AVERROR(ENOMEM);920 ret = AVERROR(ENOMEM);
917 goto err;921 goto err;
@@ -946,7 +950,8 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 28 unmodified lines
946 } else { // found field marker, unescape second field950 } else { // found field marker, unescape second field
947 if (avctx->hwaccel)951 if (avctx->hwaccel)
948 buf_start_second_field = divider;952 buf_start_second_field = divider;
949 tmp = av_realloc_array(slices, sizeof(*slices), n_slices+1);953 av_size_mult(sizeof(*slices), n_slices+1, &next_allocated);
954 tmp = next_allocated ? av_fast_realloc(slices, &slices_allocated, next_allocated) : NULL;
950 if (!tmp) {955 if (!tmp) {
951 ret = AVERROR(ENOMEM);956 ret = AVERROR(ENOMEM);
952 goto err;957 goto err;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t