Skip to content

Commit

Permalink
Fix dereference after NULL check in backend main_helpers.
Browse files Browse the repository at this point in the history
Also fix possible socket leaks.  Fixes Coverity 746814.
  • Loading branch information
gigem committed Jun 19, 2013
1 parent 06d6f4b commit 842cb94
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mythtv/programs/mythbackend/main_helpers.cpp
Expand Up @@ -432,6 +432,7 @@ int connect_to_master(void)
{
LOG(VB_GENERAL, LOG_ERR, "Master backend is incompatible with "
"this backend.\nCannot become a slave.");
tempMonitorConnection->DecrRef();
return GENERIC_EXIT_CONNECT_ERROR;
}

Expand Down Expand Up @@ -464,12 +465,14 @@ int connect_to_master(void)
{
timeCheck.push_back("QUERY_TIME_ZONE");
tempMonitorConnection->SendReceiveStringList(timeCheck);
tempMonitorConnection->WriteStringList(tempMonitorDone);
}
if (timeCheck.size() < 3)
{
if (tempMonitorConnection)
tempMonitorConnection->DecrRef();
return GENERIC_EXIT_SOCKET_ERROR;
}
tempMonitorConnection->WriteStringList(tempMonitorDone);

QDateTime our_time = MythDate::current();
QDateTime master_time = MythDate::fromString(timeCheck[2]);
Expand All @@ -481,7 +484,8 @@ int connect_to_master(void)
QString("Current time on the master backend differs by "
"%1 seconds from time on this system. Exiting.")
.arg(timediff));
tempMonitorConnection->DecrRef();
if (tempMonitorConnection)
tempMonitorConnection->DecrRef();
return GENERIC_EXIT_INVALID_TIME;
}

Expand Down

0 comments on commit 842cb94

Please sign in to comment.