Fix a memory in dumping functions with TRANSFORMs
authorDaniel Gustafsson <[email protected]>
Wed, 11 Dec 2024 11:48:22 +0000 (12:48 +0100)
committerDaniel Gustafsson <[email protected]>
Wed, 11 Dec 2024 11:48:22 +0000 (12:48 +0100)
The gneration of the dump clause for functions with TRANSFORM
calls would  the memory for holding the result of the Oid
array parsing.  Fix by freeing.

While in there, switch to using pg_malloc instead of palloc in
order to be consistent with the rest of the file.

Author: Oleg Tselebrovskiy <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Discussion: https://postgr.es/m/baf1ae4511288e5b421f41e79a3df1a0@postgrespro.ru

src/bin/pg_dump/pg_dump.c

index ec0cdf4ed74f3e9c38fe59f8a200bccf923f26c8..89276524ae011b63c74503af88e8a946131d0a3e 100644 (file)
@@ -12531,7 +12531,7 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
 
    if (*protrftypes)
    {
-       Oid        *typeids = palloc(FUNC_MAX_ARGS * sizeof(Oid));
+       Oid        *typeids = pg_malloc(FUNC_MAX_ARGS * sizeof(Oid));
        int         i;
 
        appendPQExpBufferStr(q, " TRANSFORM ");
@@ -12543,6 +12543,8 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
            appendPQExpBuffer(q, "FOR TYPE %s",
                              getFormattedTypeName(fout, typeids[i], zeroAsNone));
        }
+
+       free(typeids);
    }
 
    if (prokind[0] == PROKIND_WINDOW)