Commit 359dea28 authored by Peter Eisentraut's avatar Peter Eisentraut

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
parent d8e5b342
...@@ -9477,18 +9477,21 @@ dumpCast(Archive *fout, CastInfo *cast) ...@@ -9477,18 +9477,21 @@ dumpCast(Archive *fout, CastInfo *cast)
appendPQExpBuffer(defqry, "WITH INOUT"); appendPQExpBuffer(defqry, "WITH INOUT");
break; break;
case COERCION_METHOD_FUNCTION: case COERCION_METHOD_FUNCTION:
{ if (funcInfo)
char *fsig = format_function_signature(fout, funcInfo, true); {
char *fsig = format_function_signature(fout, funcInfo, true);
/* /*
* Always qualify the function name, in case it is not in * Always qualify the function name, in case it is not in
* pg_catalog schema (format_function_signature won't qualify it). * pg_catalog schema (format_function_signature won't qualify it).
*/ */
appendPQExpBuffer(defqry, "WITH FUNCTION %s.%s", appendPQExpBuffer(defqry, "WITH FUNCTION %s.%s",
fmtId(funcInfo->dobj.namespace->dobj.name), fsig); fmtId(funcInfo->dobj.namespace->dobj.name), fsig);
free(fsig); free(fsig);
}
else
write_msg(NULL, "WARNING: bogus value in pg_cast.castfunc or pg_cast.castmethod field\n");
break; break;
}
default: default:
write_msg(NULL, "WARNING: bogus value in pg_cast.castmethod field\n"); write_msg(NULL, "WARNING: bogus value in pg_cast.castmethod field\n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment