[x265] [PATCH] Fix memory leak in analysis-multi-pass stats file renaming
aruna at multicorewareinc.com
aruna at multicorewareinc.com
Thu Dec 29 10:59:21 CET 2016
# HG changeset patch
# User Aruna Matheswaran
# Date 1483003502 -19800
# Thu Dec 29 14:55:02 2016 +0530
# Node ID f072c4a62bccb69c3159083b0d5c49031986e09d
# Parent ba0fac368a6d6d255db52727b1f40c8dea089628
Fix memory leak in analysis-multi-pass stats file renaming
diff -r ba0fac368a6d -r f072c4a62bcc source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Thu Dec 29 12:32:27 2016 +0530
+++ b/source/encoder/encoder.cpp Thu Dec 29 14:55:02 2016 +0530
@@ -362,7 +362,13 @@
if (m_param->rc.bStatWrite)
{
char* temp = strcatFilename(name, ".temp");
- m_analysisFileOut = fopen(temp, "wb");
+ if (!temp)
+ m_aborted = true;
+ else
+ {
+ m_analysisFileOut = fopen(temp, "wb");
+ X265_FREE(temp);
+ }
if (!m_analysisFileOut)
{
x265_log(NULL, X265_LOG_ERROR, "Analysis 2 pass: failed to open file %s\n", temp);
@@ -466,6 +472,7 @@
if (m_analysisFileIn)
fclose(m_analysisFileIn);
+
if (m_analysisFileOut)
{
int bError = 1;
@@ -473,13 +480,17 @@
const char* name = m_param->analysisFileName;
if (!name)
name = defaultAnalysisFileName;
- x265_unlink(name);
char* temp = strcatFilename(name, ".temp");
- bError = x265_rename(temp, name);
+ if (temp)
+ {
+ x265_unlink(name);
+ bError = x265_rename(temp, name);
+ }
if (bError)
{
x265_log(m_param, X265_LOG_ERROR, "failed to rename analysis stats file to \"%s\"\n", name);
}
+ X265_FREE(temp);
}
if (m_param)
@@ -919,13 +930,12 @@
frameEnc = m_lookahead->getDecidedPicture();
if (frameEnc && !pass)
{
- int sliceType = frameEnc->m_lowres.sliceType;
if (m_param->analysisMultiPassRefine || m_param->analysisMultiPassDistortion)
{
- allocAnalysis2Pass(&frameEnc->m_analysis2Pass, sliceType);
+ allocAnalysis2Pass(&frameEnc->m_analysis2Pass, frameEnc->m_lowres.sliceType);
frameEnc->m_analysis2Pass.poc = frameEnc->m_poc;
if (m_param->rc.bStatRead)
- readAnalysis2PassFile(&frameEnc->m_analysis2Pass, frameEnc->m_poc, sliceType);
+ readAnalysis2PassFile(&frameEnc->m_analysis2Pass, frameEnc->m_poc, frameEnc->m_lowres.sliceType);
}
if (curEncoder->m_reconfigure)
{
@@ -2558,7 +2568,6 @@
return;
}
/* Now arrived at the right frame, read the record */
- analysis2Pass->poc = poc;
analysis2Pass->frameRecordSize = frameRecordSize;
uint8_t* tempBuf = NULL, *depthBuf = NULL;
More information about the x265-devel
mailing list