minor leaks in pg_dump (PG tarball 10.6)

Поиск
Список
Период
Сортировка
От Pavel Raiskup
Тема minor leaks in pg_dump (PG tarball 10.6)
Дата
Msg-id 2183976.vkCJMhdhmF@nb.usersys.redhat.com
обсуждение исходный текст
Ответы Re: minor leaks in pg_dump (PG tarball 10.6)  (Stephen Frost <sfrost@snowman.net>)
Список pgsql-hackers
Among other reports (IMO clearly non-issues), I'm sending patch which
fixes/points to a few resource leaks detected by Coverity that might be
worth fixing.  If they are not, feel free to ignore this mail.

Pavel

diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index 8a93ace9fa..475d6dbd73 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -95,6 +95,8 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
     {
         if (!parsePGArray(racls, &raclitems, &nraclitems))
         {
+            if (aclitems)
+                free(aclitems);
             if (raclitems)
                 free(raclitems);
             return false;
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index d583154fba..731a08c15c 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -8284,7 +8284,6 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
             res = ExecuteSqlQuery(fout, q->data, PGRES_TUPLES_OK);
 
             numDefaults = PQntuples(res);
-            attrdefs = (AttrDefInfo *) pg_malloc(numDefaults * sizeof(AttrDefInfo));
 
             for (j = 0; j < numDefaults; j++)
             {
@@ -8304,6 +8303,8 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
                 if (tbinfo->attisdropped[adnum - 1])
                     continue;
 
+                attrdefs = (AttrDefInfo *) pg_malloc(numDefaults * sizeof(AttrDefInfo));
+
                 attrdefs[j].dobj.objType = DO_ATTRDEF;
                 attrdefs[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, 0));
                 attrdefs[j].dobj.catId.oid = atooid(PQgetvalue(res, j, 1));
@@ -15951,6 +15952,9 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
                                   tbinfo->attfdwoptions[j]);
             }
         }
+
+        free(ftoptions);
+        free(srvname);
     }
 
     /*





В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: don't mark indexes invalid unnecessarily
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: minor leaks in pg_dump (PG tarball 10.6)