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>
bb10
Vincas Dargis 2016-02-26 09:54:38 +02:00 committed by Mark Brand
parent defd302f64
commit 361142b5fc
1 changed files with 4 additions and 0 deletions

View File

@ -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);