summaryrefslogtreecommitdiffstats
path: root/src/sql/drivers/psql
diff options
context:
space:
mode:
authorVincas Dargis <vindrg@gmail.com>2016-02-26 09:54:38 +0200
committerMark Brand <mabrand@mabrand.nl>2016-03-01 22:46:16 +0000
commit361142b5fcd199e7c301765b0dd16227cde71080 (patch)
tree7f5b94755bfac937cc9e73e0b774e6bb957981da /src/sql/drivers/psql
parentdefd302f64f213a8764875a88788dbcea76d66f0 (diff)
PostgreSQL: Fix memory leak in subscribeToNotification() and unsubscribeFromNotification()
Both subscribeToNotification() and unsubscribeFromNotification() are missing PQclear calls to free PGresult. Task-number: QTBUG-51412 Change-Id: I72ec3438b22bc99205c984b67b922766bcdbed08 Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'src/sql/drivers/psql')
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index de1f1638fd..4f36e0b513 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -1390,8 +1390,10 @@ bool QPSQLDriver::subscribeToNotification(const QString &name)
PGresult *result = d->exec(query);
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
setLastError(qMakeError(tr("Unable to subscribe"), QSqlError::StatementError, d, result));
+ PQclear(result);
return false;
}
+ PQclear(result);
if (!d->sn) {
d->sn = new QSocketNotifier(socket, QSocketNotifier::Read);
@@ -1423,8 +1425,10 @@ bool QPSQLDriver::unsubscribeFromNotification(const QString &name)
PGresult *result = d->exec(query);
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
setLastError(qMakeError(tr("Unable to unsubscribe"), QSqlError::StatementError, d, result));
+ PQclear(result);
return false;
}
+ PQclear(result);
d->seid.removeAll(name);