shithub: libvpx

Download patch

ref: 28cc5f3646bac9d01e583621f611303f738424f0
parent: 1140d8f2e200a284b56e3b498e4cad0ce8e5d1d2
author: Jerome Jiang <[email protected]>
date: Thu Jun 6 11:38:13 EDT 2019

vp8: fix leak in vp8e_mr_alloc_mem

BUG=webm:1596

Change-Id: I09ba00a7b7ad331671a7a285a2ac5630d8b62199

--- a/vp8/vp8_cx_iface.c
+++ b/vp8/vp8_cx_iface.c
@@ -579,7 +579,7 @@
 
 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 @@
 
   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;