Hi,

if I manually close the DB it will later be finalized which will lead to a
double free.
>From 8ca34aa7544bf1a6ccdd3aa1eaf29c59d9936f4d Mon Sep 17 00:00:00 2001
From: Holger Hans Peter Freyther <[email protected]>
Date: Sat, 23 Apr 2011 10:06:14 +0200
Subject: [PATCH] dbd-postgres: Fix a double free on connection close

It was possible that if a Connection was closed and later
finalized that we would free the handle twice and segfault.

2011-04-23  Holger Hans Peter Freyther  <[email protected]>

	* Connection.st: Release the handle only once.
---
 packages/dbd-postgresql/ChangeLog     |    4 ++++
 packages/dbd-postgresql/Connection.st |    4 +++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/packages/dbd-postgresql/ChangeLog b/packages/dbd-postgresql/ChangeLog
index 9b02b33..a5caf6f 100644
--- a/packages/dbd-postgresql/ChangeLog
+++ b/packages/dbd-postgresql/ChangeLog
@@ -1,3 +1,7 @@
+2011-04-23  Holger Hans Peter Freyther  <[email protected]>
+
+	* Connection.st: Release the handle only once.
+
 2011-04-11  Holger Hans Peter Freyther  <[email protected]>
 
 	* ResultSet.st: Handle multiple calls to primClear.
diff --git a/packages/dbd-postgresql/Connection.st b/packages/dbd-postgresql/Connection.st
index 65adad1..133b2bf 100644
--- a/packages/dbd-postgresql/Connection.st
+++ b/packages/dbd-postgresql/Connection.st
@@ -131,7 +131,9 @@ Connection subclass: PGConnection [
 
     close [
 	<category: 'implementations'>
-	handle finish
+	handle ifNotNil: [
+	    handle finish.
+	    handle := nil].
     ]
 
     beginTransaction [
-- 
1.7.4.1

_______________________________________________
help-smalltalk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to