diff --git a/src/backend/utils/adt/pg_upgrade_support.c b/src/backend/utils/adt/pg_upgrade_support.c index 883378e524..1887e455e5 100644 --- a/src/backend/utils/adt/pg_upgrade_support.c +++ b/src/backend/utils/adt/pg_upgrade_support.c @@ -129,16 +129,28 @@ binary_upgrade_set_next_pg_authid_oid(PG_FUNCTION_ARGS) Datum binary_upgrade_create_empty_extension(PG_FUNCTION_ARGS) { - text *extName = PG_GETARG_TEXT_PP(0); - text *schemaName = PG_GETARG_TEXT_PP(1); - bool relocatable = PG_GETARG_BOOL(2); - text *extVersion = PG_GETARG_TEXT_PP(3); + text *extName; + text *schemaName; + bool relocatable; + text *extVersion; Datum extConfig; Datum extCondition; List *requiredExtensions; CHECK_IS_BINARY_UPGRADE; + /* We must check these things before dereferencing the arguments */ + if (PG_ARGISNULL(0) || + PG_ARGISNULL(1) || + PG_ARGISNULL(2) || + PG_ARGISNULL(3)) + elog(ERROR, "null argument to binary_upgrade_create_empty_extension is not allowed"); + + extName = PG_GETARG_TEXT_PP(0); + schemaName = PG_GETARG_TEXT_PP(1); + relocatable = PG_GETARG_BOOL(2); + extVersion = PG_GETARG_TEXT_PP(3); + if (PG_ARGISNULL(4)) extConfig = PointerGetDatum(NULL); else