[x265] CLI: free memory allocated for utf8 command line in Windows

Mateusz mateuszb at poczta.onet.pl
Tue May 3 12:48:15 CEST 2016


-------------- next part --------------
# HG changeset patch
# User Ma0 <mateuszb at poczta.onet.pl>
# Date 1462272360 -7200
#      Tue May 03 12:46:00 2016 +0200
# Node ID 3dc1929c045ce5deefa066a4ba6e11c657466afb
# Parent  00ea3784bd36c164c5f799c998d7a09f2cb244bf
CLI: free memory allocated for utf8 command line in Windows

diff -r 00ea3784bd36 -r 3dc1929c045c source/x265.cpp
--- a/source/x265.cpp	Thu Apr 28 09:59:30 2016 +0200
+++ b/source/x265.cpp	Tue May 03 12:46:00 2016 +0200
@@ -547,6 +547,7 @@
     GetConsoleTitle(orgConsoleTitle, CONSOLE_TITLE_SIZE);
     SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED);
 #if _WIN32
+    char** orgArgv = argv;
     get_argv_utf8(&argc, &argv);
 #endif
 
@@ -779,6 +780,14 @@
     SetConsoleTitle(orgConsoleTitle);
     SetThreadExecutionState(ES_CONTINUOUS);
 
+#if _WIN32
+    if (argv != orgArgv)
+    {
+        free(argv);
+        argv = orgArgv;
+    }
+#endif
+
 #if HAVE_VLD
     assert(VLDReportLeaks() == 0);
 #endif


More information about the x265-devel mailing list