]> granicus.if.org Git - libvpx/commitdiff
vp8: fix leak in vp8e_mr_alloc_mem
authorJerome Jiang <jianj@google.com>
Thu, 6 Jun 2019 22:38:13 +0000 (15:38 -0700)
committerJerome Jiang <jianj@google.com>
Thu, 6 Jun 2019 22:38:13 +0000 (15:38 -0700)
BUG=webm:1596

Change-Id: I09ba00a7b7ad331671a7a285a2ac5630d8b62199

vp8/vp8_cx_iface.c

index d65bf9652e41acd231e6f0499b057547c473552a..b322e92e476ce1aa58f8e4a3d4a77b21c8ef749e 100644 (file)
@@ -579,7 +579,7 @@ static vpx_codec_err_t set_screen_content_mode(vpx_codec_alg_priv_t *ctx,
 
 static vpx_codec_err_t vp8e_mr_alloc_mem(const vpx_codec_enc_cfg_t *cfg,
                                          void **mem_loc) {
-  vpx_codec_err_t res = 0;
+  vpx_codec_err_t res = VPX_CODEC_OK;
 
 #if CONFIG_MULTI_RES_ENCODING
   LOWER_RES_FRAME_INFO *shared_mem_loc;
@@ -588,12 +588,13 @@ static vpx_codec_err_t vp8e_mr_alloc_mem(const vpx_codec_enc_cfg_t *cfg,
 
   shared_mem_loc = calloc(1, sizeof(LOWER_RES_FRAME_INFO));
   if (!shared_mem_loc) {
-    res = VPX_CODEC_MEM_ERROR;
+    return VPX_CODEC_MEM_ERROR;
   }
 
   shared_mem_loc->mb_info =
       calloc(mb_rows * mb_cols, sizeof(LOWER_RES_MB_INFO));
   if (!(shared_mem_loc->mb_info)) {
+    free(shared_mem_loc);
     res = VPX_CODEC_MEM_ERROR;
   } else {
     *mem_loc = (void *)shared_mem_loc;