History

avcodec/dxv: Clear ctex

same issue as with tex Fixes: 431665305/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5339599339847680 Fixes: use of uninitialized memory

Michael Niedermayer committed 1 year ago

Commit da3f5271 parent 60498001 file · +11 −3Browse files

Unified · Split

libavcodec/dxv.c+11−3
@@ -39,6 +39,7 @@ typedef struct DXVContext { · 38 unmodified lines
3939
4040 uint8_t *tex_data; // Compressed texture
4141 uint8_t *ctex_data; // Compressed chroma texture
42+ unsigned ctex_data_size;
4243
4344 int64_t tex_size; // Texture size
4445 int64_t ctex_size; // Chroma texture size
@@ -987,9 +988,14 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame, · 942 unmodified lines
987988 ctx->op_size[2] = avctx->coded_width * avctx->coded_height / 32;
988989 ctx->op_size[3] = avctx->coded_width * avctx->coded_height / 16;
989990
990− ret = av_reallocp(&ctx->ctex_data, ctx->ctex_size + AV_INPUT_BUFFER_PADDING_SIZE);
991− if (ret < 0)
992− return ret;
991+ old_size = ctx->ctex_data_size;
992+ ptr = av_fast_realloc(ctx->ctex_data, &ctx->ctex_data_size, ctx->ctex_size + AV_INPUT_BUFFER_PADDING_SIZE);
993+ if (!ptr)
994+ return AVERROR(ENOMEM);
995+ ctx->ctex_data = ptr;
996+ if (old_size < ctx->ctex_data_size)
997+ memset(ctx->ctex_data + old_size, 0, ctx->ctex_data_size - old_size);
998+
993999 for (i = 0; i < 4; i++) {
9941000 ret = av_reallocp(&ctx->op_data[i], ctx->op_size[i]);
9951001 if (ret < 0)
@@ -1081,6 +1087,8 @@ static av_cold int dxv_close(AVCodecContext *avctx) · 85 unmodified lines
10811087
10821088 av_freep(&ctx->tex_data);
10831089 av_freep(&ctx->ctex_data);
1090+ ctx->ctex_data_size = 0;
1091+
10841092 av_freep(&ctx->op_data[0]);
10851093 av_freep(&ctx->op_data[1]);
10861094 av_freep(&ctx->op_data[2]);

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