You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
truemotion2: Check memory allocation
This commit is contained in:
committed by
Luca Barbato
parent
28fb80dcbf
commit
e1ea365f7e
@@ -171,6 +171,10 @@ static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
|
|||||||
huff.nums = av_mallocz(huff.max_num * sizeof(int));
|
huff.nums = av_mallocz(huff.max_num * sizeof(int));
|
||||||
huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t));
|
huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t));
|
||||||
huff.lens = av_mallocz(huff.max_num * sizeof(int));
|
huff.lens = av_mallocz(huff.max_num * sizeof(int));
|
||||||
|
if (!huff.nums || !huff.bits || !huff.lens) {
|
||||||
|
res = AVERROR(ENOMEM);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
res = tm2_read_tree(ctx, 0, 0, &huff);
|
res = tm2_read_tree(ctx, 0, 0, &huff);
|
||||||
|
|
||||||
@@ -193,10 +197,16 @@ static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
|
|||||||
code->bits = huff.max_bits;
|
code->bits = huff.max_bits;
|
||||||
code->length = huff.max_num;
|
code->length = huff.max_num;
|
||||||
code->recode = av_malloc(code->length * sizeof(int));
|
code->recode = av_malloc(code->length * sizeof(int));
|
||||||
|
if (!code->recode) {
|
||||||
|
res = AVERROR(ENOMEM);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
for (i = 0; i < code->length; i++)
|
for (i = 0; i < code->length; i++)
|
||||||
code->recode[i] = huff.nums[i];
|
code->recode[i] = huff.nums[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
/* free allocated memory */
|
/* free allocated memory */
|
||||||
av_free(huff.nums);
|
av_free(huff.nums);
|
||||||
av_free(huff.bits);
|
av_free(huff.bits);
|
||||||
|
Reference in New Issue
Block a user