[FFmpeg-devel] [PATCH] bgmc: fix sizeof argument

Thilo Borgmann thilo.borgmann at googlemail.com
Sun Oct 14 17:43:23 CEST 2012


This should fix the coverity CIDs 700724 and 608084 by dereferencing the
pointers correctly.

-Thilo
-------------- next part --------------
>From 30f1e44c18e9bb1cc51d1bac762e435fc434b913 Mon Sep 17 00:00:00 2001
From: Thilo Borgmann <thilo.borgmann at googlemail.com>
Date: Sun, 14 Oct 2012 17:38:21 +0200
Subject: [PATCH] bgmc: fix sizeof arguments (should fix CIDs: 700724 and 608084)

---
 libavcodec/bgmc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/bgmc.c b/libavcodec/bgmc.c
index e4f937c..8b84ebf 100644
--- a/libavcodec/bgmc.c
+++ b/libavcodec/bgmc.c
@@ -458,8 +458,8 @@ static uint8_t *bgmc_lut_getp(uint8_t *lut, int *lut_status, int delta)
 /** Initialize the lookup table arrays */
 int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
 {
-    *cf_lut        = av_malloc(sizeof(*cf_lut)        * LUT_BUFF * 16 * LUT_SIZE);
-    *cf_lut_status = av_malloc(sizeof(*cf_lut_status) * LUT_BUFF);
+    *cf_lut        = av_malloc(sizeof(**cf_lut)        * LUT_BUFF * 16 * LUT_SIZE);
+    *cf_lut_status = av_malloc(sizeof(**cf_lut_status) * LUT_BUFF);
 
     if (!cf_lut || !cf_lut_status) {
         ff_bgmc_end(cf_lut, cf_lut_status);
@@ -467,7 +467,7 @@ int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
         return AVERROR(ENOMEM);
     } else {
         // initialize lut_status buffer to a value never used to compare against
-        memset(*cf_lut_status, -1, sizeof(*cf_lut_status) * LUT_BUFF);
+        memset(*cf_lut_status, -1, sizeof(**cf_lut_status) * LUT_BUFF);
     }
 
     return 0;
-- 
1.7.4.3



More information about the ffmpeg-devel mailing list