summaryrefslogtreecommitdiff
path: root/packages/fcl-db
diff options
context:
space:
mode:
authormarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-03-05 00:32:48 +0000
committermarco <marco@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-03-05 00:32:48 +0000
commitd0e9bd53b8e1fe92876fc4ad7c7e4600a38a2aa5 (patch)
tree63c73f762ca6cb494840f2eebdcca4d72c40236e /packages/fcl-db
parent64e5508e07897eb0c7915319a23b0f8b80947804 (diff)
downloadfpc-d0e9bd53b8e1fe92876fc4ad7c7e4600a38a2aa5.tar.gz
* fixed minor logic errors in pqconnection that lead to double free (actually pqclear()). Mantis 17784 by Andrew Brunner
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@17078 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-db')
-rw-r--r--packages/fcl-db/src/sqldb/postgres/pqconnection.pp14
1 files changed, 9 insertions, 5 deletions
diff --git a/packages/fcl-db/src/sqldb/postgres/pqconnection.pp b/packages/fcl-db/src/sqldb/postgres/pqconnection.pp
index 664b8a2bd9..4c479f80c4 100644
--- a/packages/fcl-db/src/sqldb/postgres/pqconnection.pp
+++ b/packages/fcl-db/src/sqldb/postgres/pqconnection.pp
@@ -561,10 +561,11 @@ begin
res := pqexec(tr.PGConn,pchar('deallocate prepst'+nr));
if (PQresultStatus(res) <> PGRES_COMMAND_OK) then
begin
+ pqclear(res);
+ DatabaseError(SErrPrepareFailed + ' (PostgreSQL: ' + PQerrorMessage(tr.PGConn) + ')',self)
+ end
+ else
pqclear(res);
- DatabaseError(SErrPrepareFailed + ' (PostgreSQL: ' + PQerrorMessage(tr.PGConn) + ')',self)
- end;
- pqclear(res);
end;
FPrepared := False;
end;
@@ -641,9 +642,12 @@ begin
s := Statement;
res := pqexec(tr.PGConn,pchar(s));
if (PQresultStatus(res) in [PGRES_COMMAND_OK,PGRES_TUPLES_OK]) then
- pqclear(res);
+ begin
+ pqclear(res);
+ res:=nil;
+ end;
end;
- if not (PQresultStatus(res) in [PGRES_COMMAND_OK,PGRES_TUPLES_OK]) then
+ if assigned(res) and not (PQresultStatus(res) in [PGRES_COMMAND_OK,PGRES_TUPLES_OK]) then
begin
s := PQerrorMessage(tr.PGConn);
pqclear(res);