]> granicus.if.org Git - postgresql/commitdiff
Check version before allocating PQExpBuffer
authorStephen Frost <sfrost@snowman.net>
Mon, 15 Jul 2013 01:17:59 +0000 (21:17 -0400)
committerStephen Frost <sfrost@snowman.net>
Mon, 15 Jul 2013 01:21:15 +0000 (21:21 -0400)
In pg_dump.c:getEventTriggers, check what major version we are on
before calling createPQExpBuffer() to avoid leaking that bit of
memory.

Leak discovered by the Coverity scanner.

Back-patch to 9.3 where support for dumping event triggers was
added.

src/bin/pg_dump/pg_dump.c

index becc82be91e92e8400458450a397b47044ba1a2e..f74935e0b93e8b22f4cc82bc3fa9707865225f1f 100644 (file)
@@ -5746,7 +5746,7 @@ EventTriggerInfo *
 getEventTriggers(Archive *fout, int *numEventTriggers)
 {
        int                     i;
-       PQExpBuffer query = createPQExpBuffer();
+       PQExpBuffer query;
        PGresult   *res;
        EventTriggerInfo *evtinfo;
        int                     i_tableoid,
@@ -5766,6 +5766,8 @@ getEventTriggers(Archive *fout, int *numEventTriggers)
                return NULL;
        }
 
+       query = createPQExpBuffer();
+
        /* Make sure we are in proper schema */
        selectSourceSchema(fout, "pg_catalog");