diff options
author | randomdan <randomdan@localhost> | 2011-12-14 20:00:42 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2011-12-14 20:00:42 +0000 |
commit | f3ae13b9eda19e4074ef1582bab5bb1336fb8d25 (patch) | |
tree | 2376d1bf32f046cf2681e6c8c638ab1b8901d289 | |
parent | Allow PQ_TUPLES_OK as an ok reply for modify commands (for cases when a funct... (diff) | |
download | libdbpp-postgresql-f3ae13b9eda19e4074ef1582bab5bb1336fb8d25.tar.bz2 libdbpp-postgresql-f3ae13b9eda19e4074ef1582bab5bb1336fb8d25.tar.xz libdbpp-postgresql-f3ae13b9eda19e4074ef1582bab5bb1336fb8d25.zip |
Fix double free on cursor error
-rw-r--r-- | libpqpp/selectcommand.cpp | 7 |
1 files 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()) { |