Skip to content

Commit

Permalink
Fix a memory leak in mythcommflag
Browse files Browse the repository at this point in the history
ClassicCommDetector::ProcessFrame leaked vast amounts of memory if the
blank-frame method is not enabled.
  • Loading branch information
John Patrick Poet committed May 26, 2011
1 parent fb5912d commit f442cff
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mythtv/programs/mythcommflag/ClassicCommDetector.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -753,13 +753,17 @@ void ClassicCommDetector::ProcessFrame(VideoFrame *frame,
{ {
VERBOSE(VB_COMMFLAG, "CommDetect: Invalid video frame or codec, " VERBOSE(VB_COMMFLAG, "CommDetect: Invalid video frame or codec, "
"unable to process frame."); "unable to process frame.");
delete[] rowMax;
delete[] colMax;
return; return;
} }


if (!width || !height) if (!width || !height)
{ {
VERBOSE(VB_COMMFLAG, "CommDetect: Width or Height is 0, " VERBOSE(VB_COMMFLAG, "CommDetect: Width or Height is 0, "
"unable to process frame."); "unable to process frame.");
delete[] rowMax;
delete[] colMax;
return; return;
} }


Expand Down Expand Up @@ -863,6 +867,7 @@ void ClassicCommDetector::ProcessFrame(VideoFrame *frame,
bottomDarkRow = y; bottomDarkRow = y;


delete[] rowMax; delete[] rowMax;
rowMax = 0;


for(int x = commDetectBorder; x < (width - commDetectBorder); for(int x = commDetectBorder; x < (width - commDetectBorder);
x += horizSpacing) x += horizSpacing)
Expand All @@ -879,6 +884,7 @@ void ClassicCommDetector::ProcessFrame(VideoFrame *frame,
rightDarkCol = x; rightDarkCol = x;


delete[] colMax; delete[] colMax;
colMax = 0;


if ((topDarkRow > commDetectBorder) && if ((topDarkRow > commDetectBorder) &&
(topDarkRow < (height * .20)) && (topDarkRow < (height * .20)) &&
Expand Down Expand Up @@ -976,6 +982,8 @@ void ClassicCommDetector::ProcessFrame(VideoFrame *frame,
#endif #endif


framesProcessed++; framesProcessed++;
delete[] rowMax;
delete[] colMax;
} }


void ClassicCommDetector::ClearAllMaps(void) void ClassicCommDetector::ClearAllMaps(void)
Expand Down

0 comments on commit f442cff

Please sign in to comment.