diff options
author | Stian Sandvik Thomassen <stian.thomassen@nokia.com> | 2009-07-09 03:26:18 (GMT) |
---|---|---|
committer | Stian Sandvik Thomassen <stian.thomassen@nokia.com> | 2009-07-09 03:26:18 (GMT) |
commit | 99cda3446c6ff5c3da4fe8fb4bc8869497f8da8b (patch) | |
tree | 46d89795a546730db4382b015a69f2bfcd13aae9 | |
parent | 53228e1b1993524fb1422a8363647b468b3c7c8d (diff) | |
download | Qt-99cda3446c6ff5c3da4fe8fb4bc8869497f8da8b.zip Qt-99cda3446c6ff5c3da4fe8fb4bc8869497f8da8b.tar.gz Qt-99cda3446c6ff5c3da4fe8fb4bc8869497f8da8b.tar.bz2 |
Plugged possible memory leak in getPSQLVersion()
Call PQclear() regardless of the status of the result returned by
PQexec().
Reviewed-by: Bill King
-rw-r--r-- | src/sql/drivers/psql/qsql_psql.cpp | 4 |
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 4eccf4b..147cd6d 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."); |