Repair multiple memory leaks in getTables(), including one that could
authorTom Lane <[email protected]>
Sat, 20 Mar 2004 18:12:50 +0000 (18:12 +0000)
committerTom Lane <[email protected]>
Sat, 20 Mar 2004 18:12:50 +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 0a85fe007867bfef2319c864bc474440c8c261f8..680120efe4b24b62e576a1654f8882cdb545b4e8 100644 (file)
@@ -2311,6 +2311,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
                        else
                                tblinfo[i].pkIndexOid = NULL;
 
+                       PQclear(res2);
                }
                else
                        tblinfo[i].pkIndexOid = NULL;
@@ -2383,6 +2384,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
                                perror("strdup");
                                exit(1);
                        }
+                       PQclear(res2);
                }
                else
                        tblinfo[i].primary_key_name = NULL;
@@ -2533,6 +2535,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
                                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));