mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
Prevent a double-free
This can occur because prior to this, there is a code path that looks
like this:
primaryConn = myLocalConn
CloseConnections will subsequently try to free both with PQFinish.
I'm not sure if this is the right fix -- it's more of hack -- without
more information about design intention.
One reasonable alternative would be to have CloseConnections perform
this check itself. As-is I am pretty sure that this fix leaves a
signal-race (when CloseConnections is called, without the check, in
the interrupt handler) unfixed.
Signed-off-by: Dan Farina <drfarina@acm.org>
Signed-off-by: Peter van Hardenberg <pvh@heroku.com>
This commit is contained in:
committed by
Peter van Hardenberg
parent
6cea339697
commit
309bb92d95
@@ -180,6 +180,10 @@ main(int argc, char **argv)
|
|||||||
MonitorCheck();
|
MonitorCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Prevent a double-free */
|
||||||
|
if (primaryConn == myLocalConn)
|
||||||
|
myLocalConn = NULL;
|
||||||
|
|
||||||
/* close the connection to the database and cleanup */
|
/* close the connection to the database and cleanup */
|
||||||
CloseConnections();
|
CloseConnections();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user