Skip to content

Commit

Permalink
Add a bit more error checking in exec() and prepare()
Browse files Browse the repository at this point in the history
The lack of null check on m_db caused a few segfaults during shutdown.  While
rare, this should prevent those crashes with minimal extra code involved.
  • Loading branch information
Beirdo committed May 28, 2011
1 parent 94f90f6 commit 063e45e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mythtv/libs/libmythbase/mythdbcon.cpp
Expand Up @@ -551,6 +551,12 @@ bool MSqlQuery::exec()
{
// Database connection down. Try to restart it, give up if it's still
// down
if (!m_db)
{
// Database structure's been deleted
return false;
}

if (!m_db->isOpen() && !m_db->Reconnect())
{
VERBOSE(VB_IMPORTANT, "MySQL server disconnected");
Expand Down Expand Up @@ -660,6 +666,12 @@ bool MSqlQuery::prepare(const QString& query)

// Database connection down. Try to restart it, give up if it's still
// down
if (!m_db)
{
// Database structure has been deleted...
return false;
}

if (!m_db->isOpen() && !m_db->Reconnect())
{
VERBOSE(VB_IMPORTANT, "MySQL server disconnected");
Expand Down

0 comments on commit 063e45e

Please sign in to comment.