Skip to content

Commit f459099

Browse files
committed
The attached patch fixes 2 memory leaks in pg_dump, as well as corrects
a spelling mistake and deletes an antiquated comment. Neil Conway
1 parent 43b0f2e commit f459099

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.49 2002/05/29 01:49:57 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.50 2002/07/02 05:49:51 momjian Exp $
1919
*
2020
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
2121
*
@@ -2371,7 +2371,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn)
23712371
/* Sort it, but ignore the header entries */
23722372
qsort(&(tea[1]), AH->tocCount, sizeof(TocEntry *), fn);
23732373

2374-
/* Rebuild list: this works becuase we have headers at each end */
2374+
/* Rebuild list: this works because we have headers at each end */
23752375
for (i = 1; i <= AH->tocCount; i++)
23762376
{
23772377
tea[i]->next = tea[i + 1];

src/bin/pg_dump/pg_dump.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*
2424
* IDENTIFICATION
25-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.267 2002/06/20 20:29:41 momjian Exp $
25+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.268 2002/07/02 05:49:51 momjian Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -967,10 +967,10 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv)
967967
write_msg(NULL, "SQL command to dump the contents of table \"%s\" failed: PQendcopy() failed.\n", classname);
968968
write_msg(NULL, "Error message from server: %s", PQerrorMessage(g_conn));
969969
write_msg(NULL, "The command was: %s\n", q->data);
970-
PQclear(res);
971970
exit_nicely();
972971
}
973972

973+
PQclear(res);
974974
destroyPQExpBuffer(q);
975975
return 1;
976976
}
@@ -4758,6 +4758,15 @@ dumpOneTable(Archive *fout, TableInfo *tbinfo, TableInfo *g_tblinfo)
47584758
/* Dump Table Comments */
47594759
dumpTableComment(fout, tbinfo, reltypename, commentDeps);
47604760

4761+
if (commentDeps)
4762+
{
4763+
for (j = 0; (*commentDeps)[j] != NULL; j++)
4764+
{
4765+
free((void *) (*commentDeps)[j]);
4766+
}
4767+
free(commentDeps);
4768+
}
4769+
47614770
destroyPQExpBuffer(query);
47624771
destroyPQExpBuffer(q);
47634772
destroyPQExpBuffer(delq);

src/bin/pg_dump/pg_dump.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_dump.h,v 1.88 2002/06/20 20:29:41 momjian Exp $
9+
* $Id: pg_dump.h,v 1.89 2002/07/02 05:49:52 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -156,11 +156,6 @@ extern char g_comment_end[10];
156156

157157
extern char g_opaque_type[10]; /* name for the opaque type */
158158

159-
/* pg_dump is really two programs in one
160-
one version works with postgres v4r2
161-
and the other works with postgreSQL
162-
the common routines are declared here
163-
*/
164159
/*
165160
* common utility functions
166161
*/

0 commit comments

Comments
 (0)