Repair multiple memory leaks in getTables(), including one that could
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 20 Mar 2004 18:12:32 +0000 (18:12 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 20 Mar 2004 18:12:32 +0000 (18:12 +0000)
easily exhaust memory on databases with more than a few hundred triggers.
I don't expect any more releases of these old versions, but let's put the
fix in CVS just so it's archived.

src/bin/pg_dump/pg_dump.c

index 1d20a3deceaa3724d0a4b601cfe8641ea7e7bd2d..9a7036a818a2b879a040282e0e6781d9b7bd6144 100644 (file)
@@ -22,7 +22,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.241.2.2 2002/05/28 15:40:36 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.241.2.3 2004/03/20 18:12:32 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2403,6 +2403,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char *tablename)
            else
                tblinfo[i].pkIndexOid = NULL;
 
+           PQclear(res2);
        }
        else
            tblinfo[i].pkIndexOid = NULL;
@@ -2442,6 +2443,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char *tablename)
                write_msg(NULL, "out of memory\n");
                exit_nicely();
            }
+           PQclear(res2);
        }
        else
            tblinfo[i].primary_key_name = NULL;
@@ -2588,6 +2590,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char *tablename)
                else
                    tgfunc = strdup(finfo[findx].proname);
 
+               resetPQExpBuffer(delqry);
                appendPQExpBuffer(delqry, "DROP TRIGGER %s ", fmtId(tgname, force_quotes));
                appendPQExpBuffer(delqry, "ON %s;\n",
                                fmtId(tblinfo[i].relname, force_quotes));