dovecot-1.2: pgsql: Don't leak memory if query returns multiple ...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Mar 27 04:06:33 EET 2010
details: http://hg.dovecot.org/dovecot-1.2/rev/a39372cd040c
changeset: 9556:a39372cd040c
user: Timo Sirainen <tss at iki.fi>
date: Sat Mar 27 04:06:20 2010 +0200
description:
pgsql: Don't leak memory if query returns multiple results.
Found by Rainer Weikusat.
diffstat:
src/lib-sql/driver-pgsql.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diffs (33 lines):
diff -r 0cf38dcd8ced -r a39372cd040c src/lib-sql/driver-pgsql.c
--- a/src/lib-sql/driver-pgsql.c Sat Mar 27 03:54:00 2010 +0200
+++ b/src/lib-sql/driver-pgsql.c Sat Mar 27 04:06:20 2010 +0200
@@ -249,13 +249,17 @@
static void consume_results(struct pgsql_db *db)
{
- do {
- if (!PQconsumeInput(db->pg))
- break;
+ PGresult *pgres;
+ while (PQconsumeInput(db->pg)) {
if (PQisBusy(db->pg))
return;
- } while (PQgetResult(db->pg) != NULL);
+
+ pgres = PQgetResult(db->pg);
+ if (pgres == NULL)
+ break;
+ PQclear(pgres);
+ }
if (PQstatus(db->pg) == CONNECTION_BAD)
io_remove_closed(&db->io);
@@ -280,6 +284,7 @@
if (result->pgres != NULL) {
PQclear(result->pgres);
+ result->pgres = NULL;
/* we'll have to read the rest of the results as well */
i_assert(db->io == NULL);
More information about the dovecot-cvs
mailing list