Skip to content

Commit 3026493

Browse files
committed
This patch fixes two tiny memory leaks in pg_dump and two in pg_dumpall.
Neil Conway
1 parent cf4e603 commit 3026493

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.308 2002/11/23 03:59:08 momjian Exp $
15+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.309 2002/11/29 16:38:42 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -3226,6 +3226,7 @@ dumpOneDomain(Archive *fout, TypeInfo *tinfo)
32263226
"WHERE contypid = '%s'::pg_catalog.oid",
32273227
tinfo->oid);
32283228

3229+
PQclear(res);
32293230
res = PQexec(g_conn, chkquery->data);
32303231
if (!res ||
32313232
PQresultStatus(res) != PGRES_TUPLES_OK)
@@ -3269,6 +3270,7 @@ dumpOneDomain(Archive *fout, TypeInfo *tinfo)
32693270
destroyPQExpBuffer(q);
32703271
destroyPQExpBuffer(delq);
32713272
destroyPQExpBuffer(query);
3273+
destroyPQExpBuffer(chkquery);
32723274
}
32733275

32743276
/*

src/bin/pg_dump/pg_dumpall.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.10 2002/11/22 03:09:43 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.11 2002/11/29 16:38:42 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -403,7 +403,7 @@ dumpCreateDB(PGconn *conn)
403403

404404
for (i = 0; i < PQntuples(res); i++)
405405
{
406-
PQExpBuffer buf = createPQExpBuffer();
406+
PQExpBuffer buf;
407407
char *dbname = PQgetvalue(res, i, 0);
408408
char *dbowner = PQgetvalue(res, i, 1);
409409
char *dbencoding = PQgetvalue(res, i, 2);
@@ -413,6 +413,8 @@ dumpCreateDB(PGconn *conn)
413413
if (strcmp(dbname, "template1") == 0)
414414
continue;
415415

416+
buf = createPQExpBuffer();
417+
416418
if (output_clean)
417419
appendPQExpBuffer(buf, "DROP DATABASE %s\n;", fmtId(dbname));
418420

@@ -692,6 +694,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
692694
exit(1);
693695
}
694696
}
697+
PQclear(res);
695698

696699
return conn;
697700
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy