[x265] [PATCH] [slice] fix memory leak in weight module

chen chenm003 at 163.com
Wed Sep 7 23:39:37 CEST 2016


From 8b675dacad1c43e952f9dea827c84bfa69502782 Mon Sep 17 00:00:00 2001
From: Min Chen <chenm003 at 163.com>
Date: Wed, 7 Sep 2016 15:38:48 -0500
Subject: [PATCH] [slice] fix memory leak in weight module


---
 source/encoder/reference.cpp |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)


diff --git a/source/encoder/reference.cpp b/source/encoder/reference.cpp
index 437ea8b..864ca63 100644
--- a/source/encoder/reference.cpp
+++ b/source/encoder/reference.cpp
@@ -54,6 +54,13 @@ int MotionReference::init(PicYuv* recPic, WeightParam *wp, const x265_param& p)
     lumaStride = recPic->m_stride;
     chromaStride = recPic->m_strideC;
     numInterpPlanes = p.subpelRefine > 2 ? 3 : 1; /* is chroma satd possible? */
+
+    if (numSliceWeightedRows)
+    {
+        // Unnecessary, but avoid risk on parameters dynamic modify in future.
+        X265_FREE(numSliceWeightedRows);
+        numSliceWeightedRows = NULL;
+    }
     numSliceWeightedRows = X265_MALLOC(uint32_t, p.maxSlices);
     memset(numSliceWeightedRows, 0, p.maxSlices * sizeof(uint32_t));
 
-- 
1.7.9.msysgit.0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20160908/19571ccc/attachment.html>


More information about the x265-devel mailing list