summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStian Sandvik Thomassen <stian.thomassen@nokia.com>2009-07-09 13:26:18 +1000
committerStian Sandvik Thomassen <stian.thomassen@nokia.com>2009-07-09 13:26:18 +1000
commit99cda3446c6ff5c3da4fe8fb4bc8869497f8da8b (patch)
tree46d89795a546730db4382b015a69f2bfcd13aae9 /src
parent53228e1b1993524fb1422a8363647b468b3c7c8d (diff)
Plugged possible memory leak in getPSQLVersion()
Call PQclear() regardless of the status of the result returned by PQexec(). Reviewed-by: Bill King
Diffstat (limited to 'src')
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index 4eccf4b264..147cd6d6af 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -626,10 +626,9 @@ static QPSQLDriver::Protocol getPSQLVersion(PGconn* connection)
{
QPSQLDriver::Protocol serverVersion = QPSQLDriver::Version6;
PGresult* result = PQexec(connection, "select version()");
- int status = PQresultStatus(result);
+ int status = PQresultStatus(result);
if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK) {
QString val = QString::fromAscii(PQgetvalue(result, 0, 0));
- PQclear(result);
QRegExp rx(QLatin1String("(\\d+)\\.(\\d+)"));
rx.setMinimal(true); // enforce non-greedy RegExp
if (rx.indexIn(val) != -1) {
@@ -670,6 +669,7 @@ static QPSQLDriver::Protocol getPSQLVersion(PGconn* connection)
}
}
}
+ PQclear(result);
if (serverVersion < QPSQLDriver::Version71)
qWarning("This version of PostgreSQL is not supported and may not work.");