Skip to content

Commit

Permalink
Fix potential HLS leakage in mythtranscode, found by Coverity
Browse files Browse the repository at this point in the history
Fixes 'Resource Leak' Coverity IDs 1025906, 1025907, and 1025908 along
with a few other potential resource leaks of similar nature regarding
HLS and the AVFormatWriters it uses in transcode.cpp.
  • Loading branch information
cpinkham committed Jun 12, 2013
1 parent 1d3ffeb commit c544a47
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions mythtv/programs/mythtranscode/transcode.cpp
Expand Up @@ -277,6 +277,8 @@ int Transcode::TranscodeFile(const QString &inputname,
{
LOG(VB_GENERAL, LOG_ERR, "Transcoding aborted, error opening file.");
SetPlayerContext(NULL);
if (hls)
delete hls;
return REENCODE_ERROR;
}

Expand Down Expand Up @@ -335,6 +337,8 @@ int Transcode::TranscodeFile(const QString &inputname,
{
LOG(VB_GENERAL, LOG_INFO, "Transcoding aborted, cutlist changed");
SetPlayerContext(NULL);
if (hls)
delete hls;
return REENCODE_CUTLIST_CHANGE;
}
m_proginfo->ClearMarkupFlag(MARK_UPDATED_CUT);
Expand Down Expand Up @@ -403,6 +407,8 @@ int Transcode::TranscodeFile(const QString &inputname,
LOG(VB_GENERAL, LOG_ERR,
"Transcoding aborted, error creating AVFormatWriter.");
SetPlayerContext(NULL);
if (hls)
delete hls;
return REENCODE_ERROR;
}

Expand Down Expand Up @@ -431,6 +437,9 @@ int Transcode::TranscodeFile(const QString &inputname,
LOG(VB_GENERAL, LOG_ERR, "Transcoding aborted, error "
"creating low-bitrate AVFormatWriter.");
SetPlayerContext(NULL);
if (hls)
delete hls;
delete avfw;
return REENCODE_ERROR;
}

Expand Down Expand Up @@ -484,6 +493,9 @@ int Transcode::TranscodeFile(const QString &inputname,
{
LOG(VB_GENERAL, LOG_ERR, "Unable to create new stream");
SetPlayerContext(NULL);
delete avfw;
if (avfw2)
delete avfw2;
return REENCODE_ERROR;
}
}
Expand All @@ -496,6 +508,10 @@ int Transcode::TranscodeFile(const QString &inputname,
{
LOG(VB_GENERAL, LOG_ERR, "hls->InitForWrite() failed");
SetPlayerContext(NULL);
delete hls;
delete avfw;
if (avfw2)
delete avfw2;
return REENCODE_ERROR;
}

Expand Down Expand Up @@ -548,27 +564,45 @@ int Transcode::TranscodeFile(const QString &inputname,
{
LOG(VB_GENERAL, LOG_ERR, "avfw->Init() failed");
SetPlayerContext(NULL);
if (hls)
delete hls;
delete avfw;
if (avfw2)
delete avfw2;
return REENCODE_ERROR;
}

if (!avfw->OpenFile())
{
LOG(VB_GENERAL, LOG_ERR, "avfw->OpenFile() failed");
SetPlayerContext(NULL);
if (hls)
delete hls;
delete avfw;
if (avfw2)
delete avfw2;
return REENCODE_ERROR;
}

if (avfw2 && !avfw2->Init())
{
LOG(VB_GENERAL, LOG_ERR, "avfw2->Init() failed");
SetPlayerContext(NULL);
if (hls)
delete hls;
delete avfw;
delete avfw2;
return REENCODE_ERROR;
}

if (avfw2 && !avfw2->OpenFile())
{
LOG(VB_GENERAL, LOG_ERR, "avfw2->OpenFile() failed");
SetPlayerContext(NULL);
if (hls)
delete hls;
delete avfw;
delete avfw2;
return REENCODE_ERROR;
}

Expand Down Expand Up @@ -821,6 +855,12 @@ int Transcode::TranscodeFile(const QString &inputname,
LOG(VB_GENERAL, LOG_ERR,
"Unable to initialize MythPlayer for Transcode");
SetPlayerContext(NULL);
if (hls)
delete hls;
if (avfw)
delete avfw;
if (avfw2)
delete avfw2;
return REENCODE_ERROR;
}

Expand Down

0 comments on commit c544a47

Please sign in to comment.