[x265] [PATCH] Fix issue #508 - Crash in case of encoder fail condition

pooja at multicorewareinc.com pooja at multicorewareinc.com
Thu Sep 12 06:43:17 CEST 2019


# HG changeset patch
# User Pooja Venkatesan <pooja at multicorewareinc.com>
# Date 1565673681 -19800
#      Tue Aug 13 10:51:21 2019 +0530
# Node ID 1047791ed56e29e6fc1aa2e210998a67ea2409d9
# Parent  a092e82e6acfe7afe6a9a381e9ef52323e4e2467
Fix issue #508 - Crash in case of encoder fail condition.

This patch also includes:
Free memory for zone param.

diff -r a092e82e6acf -r 1047791ed56e source/encoder/api.cpp
--- a/source/encoder/api.cpp	Thu Aug 01 22:55:21 2019 +0200
+++ b/source/encoder/api.cpp	Tue Aug 13 10:51:21 2019 +0530
@@ -96,7 +96,12 @@
     x265_param* param = PARAM_NS::x265_param_alloc();
     x265_param* latestParam = PARAM_NS::x265_param_alloc();
     x265_param* zoneParam = PARAM_NS::x265_param_alloc();
-    if (!param || !latestParam)
+
+    if(param) PARAM_NS::x265_param_default(param);
+    if(latestParam) PARAM_NS::x265_param_default(latestParam);
+    if(zoneParam) PARAM_NS::x265_param_default(zoneParam);
+
+    if (!param || !latestParam || !zoneParam)
         goto fail;
     if (p->rc.zoneCount || p->rc.zonefileCount)
     {
@@ -106,6 +111,8 @@
     }
 
     x265_copy_params(param, p);
+    x265_copy_params(latestParam, p);
+    x265_copy_params(zoneParam, p);
     x265_log(param, X265_LOG_INFO, "HEVC encoder version %s\n", PFX(version_str));
     x265_log(param, X265_LOG_INFO, "build info %s\n", PFX(build_info_str));
 
@@ -212,6 +219,7 @@
     delete encoder;
     PARAM_NS::x265_param_free(param);
     PARAM_NS::x265_param_free(latestParam);
+    PARAM_NS::x265_param_free(zoneParam);
     return NULL;
 }
 
@@ -944,11 +952,11 @@
 
 void x265_zone_free(x265_param *param)
 {
-    if (param->rc.zonefileCount) {
+    if (param && param->rc.zonefileCount) {
         for (int i = 0; i < param->rc.zonefileCount; i++)
             x265_free(param->rc.zones[i].zoneParam);
     }
-    if (param->rc.zoneCount || param->rc.zonefileCount)
+    if (param && (param->rc.zoneCount || param->rc.zonefileCount))
         x265_free(param->rc.zones);
 }
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265.patch
Type: text/x-patch
Size: 1990 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20190912/d27c342d/attachment.bin>


More information about the x265-devel mailing list