summaryrefslogtreecommitdiff
path: root/libavcodec/truemotion2.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2013-08-28 16:48:15 +0000
committerPaul B Mahol <onemda@gmail.com>2013-08-29 10:46:42 +0000
commitd49f2603bedb780a6cedff4ac790605679cf4029 (patch)
tree06b5ae4294a07a126e14959a686611b81d3b9d5c /libavcodec/truemotion2.c
parentf3ace37a3b8c93218630a37b7df4dc195f1215a9 (diff)
truemotion2: check return value of av_malloc(z)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/truemotion2.c')
-rw-r--r--libavcodec/truemotion2.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index 6c119aca18..e083171668 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -173,6 +173,11 @@ static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
huff.bits = av_mallocz(huff.max_num * sizeof(uint32_t));
huff.lens = av_mallocz(huff.max_num * sizeof(int));
+ if (!huff.nums || !huff.bits || !huff.lens) {
+ res = AVERROR(ENOMEM);
+ goto fail;
+ }
+
res = tm2_read_tree(ctx, 0, 0, &huff);
if (huff.num != huff.max_num) {
@@ -194,10 +199,15 @@ static int tm2_build_huff_table(TM2Context *ctx, TM2Codes *code)
code->bits = huff.max_bits;
code->length = huff.max_num;
code->recode = av_malloc(code->length * sizeof(int));
+ if (!code->recode) {
+ res = AVERROR(ENOMEM);
+ goto fail;
+ }
for (i = 0; i < code->length; i++)
code->recode[i] = huff.nums[i];
}
}
+fail:
/* free allocated memory */
av_free(huff.nums);
av_free(huff.bits);