Fix a possible double free that would cause a segfault in

checkNodeConfiguration()
This commit is contained in:
Carlo Ascani
2011-07-26 18:22:06 -05:00
committed by Jaime Casanova
parent 158214acae
commit c983fdf83c
2 changed files with 6 additions and 5 deletions

View File

@@ -101,7 +101,7 @@ bool
is_witness(PGconn *conn, char *schema, char *cluster, int node_id)
{
PGresult *res;
bool result;
bool result = false;
char sqlquery[QUERY_STR_LEN];
sqlquery_snprintf(sqlquery, "SELECT witness from %s.repl_nodes where cluster = '%s' and id = %d",
@@ -115,9 +115,7 @@ is_witness(PGconn *conn, char *schema, char *cluster, int node_id)
exit(ERR_DB_QUERY);
}
if (strcmp(PQgetvalue(res, 0, 0), "f") == 0)
result = false;
else
if (PQntuples(res) == 1 && strcmp(PQgetvalue(res, 0, 0), "t") == 0)
result = true;
PQclear(res);

View File

@@ -871,7 +871,10 @@ checkNodeConfiguration(char *conninfo)
exit(ERR_BAD_CONFIG);
}
}
PQclear(res);
else
{
PQclear(res);
}
}