PostgreSQL: Fix memory leak in QPSQLDriverPrivate::getPSQLVersion()

Memory leak occurs when 'release' pointer variable is overwritten
for second use without releasing resources it is currently pointing
to. Leak occurs only in specific edge case depending on
client/server versions.

Task-number: QTBUG-49789
Change-Id: Ie5be8996ed158309f20dbb3574f956d2eb137460
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
bb10
Vincas Dargis 2015-12-05 15:20:34 +02:00 committed by Mark Brand
parent b2c7c489ab
commit e8eaf82e58
1 changed files with 1 additions and 0 deletions

View File

@ -757,6 +757,7 @@ QPSQLDriver::Protocol QPSQLDriverPrivate::getPSQLVersion()
//Client version before QPSQLDriver::Version9 only supports escape mode for bytea type,
//but bytea format is set to hex by default in PSQL 9 and above. So need to force the
//server use the old escape mode when connects to the new server with old client library.
PQclear(result);
result = exec("SET bytea_output=escape; ");
status = PQresultStatus(result);
} else if (serverVersion == QPSQLDriver::VersionUnknown) {