History

avcodec/dxv: Use av_fast_realloc() for op_data

makes things consistent

Michael Niedermayer committed 1 year ago

Commit 23655161 parent f2507db1 file · +7 −3Browse files

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

Unified · Split

libavcodec/dxv.c+7−3
@@ -46,6 +46,7 @@ typedef struct DXVContext { · 45 unmodified lines
4646 int64_t ctex_size; // Chroma texture size
4747
4848 uint8_t *op_data[4]; // Opcodes
49+ unsigned op_data_size[4];
4950 int64_t op_size[4]; // Opcodes size
5051 } DXVContext;
5152
@@ -1003,9 +1004,11 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame, · 951 unmodified lines
10031004 memset(ctx->ctex_data + old_size, 0, ctx->ctex_data_size - old_size);
10041005
10051006 for (i = 0; i < 4; i++) {
1006− ret = av_reallocp(&ctx->op_data[i], ctx->op_size[i]);
1007− if (ret < 0)
1008− return ret;
1007+ old_size = ctx->op_data_size[i];
1008+ ptr = av_fast_realloc(ctx->op_data[i], &ctx->op_data_size[i], ctx->op_size[i]);
1009+ if (!ptr)
1010+ return AVERROR(ENOMEM);
1011+ ctx->op_data[i] = ptr;
10091012 }
10101013 }
10111014
@@ -1101,6 +1104,7 @@ static av_cold int dxv_close(AVCodecContext *avctx) · 89 unmodified lines
11011104 av_freep(&ctx->op_data[1]);
11021105 av_freep(&ctx->op_data[2]);
11031106 av_freep(&ctx->op_data[3]);
1107+ memset(ctx->op_data_size, 0, sizeof(ctx->op_data_size));
11041108
11051109 return 0;
11061110 }

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