From f3ae13b9eda19e4074ef1582bab5bb1336fb8d25 Mon Sep 17 00:00:00 2001 From: randomdan Date: Wed, 14 Dec 2011 20:00:42 +0000 Subject: Fix double free on cursor error --- libpqpp/selectcommand.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libpqpp/selectcommand.cpp b/libpqpp/selectcommand.cpp index 9d3f356..dc06b36 100644 --- a/libpqpp/selectcommand.cpp +++ b/libpqpp/selectcommand.cpp @@ -20,7 +20,9 @@ PQ::SelectCommand::~SelectCommand() c->commitTx(); if (executed) { PQclear(PQexec(c->conn, ("CLOSE " + stmntName).c_str())); - PQclear(execRes); + if (execRes) { + PQclear(execRes); + } } for (unsigned int f = 0; f < fields.size(); f += 1) { delete fields[f]; @@ -67,8 +69,9 @@ PQ::SelectCommand::fetch() if (execRes) { PQclear(execRes); } + execRes = NULL; execRes = c->checkResult(PQexec(c->conn, ("FETCH 35 IN " + stmntName).c_str()), PGRES_TUPLES_OK); - nTuples = PQntuples(execRes); + nTuples = PQntuples(execRes); tuple = -1; } if (fields.empty()) { -- cgit v1.2.3