Skip to content

Commit 359dea2

Browse files
committed
pg_dump: Fix crash with invalid pg_cast row
An invalid combination of pg_cast.castfunc and pg_cast.castmethod would result in a segmentation fault. Now it prints a warning. found by Coverity
1 parent d8e5b34 commit 359dea2

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9477,18 +9477,21 @@ dumpCast(Archive *fout, CastInfo *cast)
94779477
appendPQExpBuffer(defqry, "WITH INOUT");
94789478
break;
94799479
case COERCION_METHOD_FUNCTION:
9480-
{
9481-
char *fsig = format_function_signature(fout, funcInfo, true);
9480+
if (funcInfo)
9481+
{
9482+
char *fsig = format_function_signature(fout, funcInfo, true);
94829483

9483-
/*
9484-
* Always qualify the function name, in case it is not in
9485-
* pg_catalog schema (format_function_signature won't qualify it).
9486-
*/
9487-
appendPQExpBuffer(defqry, "WITH FUNCTION %s.%s",
9488-
fmtId(funcInfo->dobj.namespace->dobj.name), fsig);
9489-
free(fsig);
9484+
/*
9485+
* Always qualify the function name, in case it is not in
9486+
* pg_catalog schema (format_function_signature won't qualify it).
9487+
*/
9488+
appendPQExpBuffer(defqry, "WITH FUNCTION %s.%s",
9489+
fmtId(funcInfo->dobj.namespace->dobj.name), fsig);
9490+
free(fsig);
9491+
}
9492+
else
9493+
write_msg(NULL, "WARNING: bogus value in pg_cast.castfunc or pg_cast.castmethod field\n");
94909494
break;
9491-
}
94929495
default:
94939496
write_msg(NULL, "WARNING: bogus value in pg_cast.castmethod field\n");
94949497
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy