From ac50f84866b22f239025bf37c9c7492cc4ce2dfd Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 2 Jul 2015 17:02:08 -0400 Subject: [PATCH] Fix misuse of TextDatumGetCString(). "TextDatumGetCString(PG_GETARG_TEXT_P(x))" is formally wrong: a text* is not a Datum. Although this coding will accidentally fail to fail on all known platforms, it risks leaking memory if a detoast step is needed, unlike "TextDatumGetCString(PG_GETARG_DATUM(x))" which is what's used elsewhere. Make pg_get_object_address() fall in line with other uses. Noted while reviewing two-arg current_setting() patch. --- src/backend/catalog/objectaddress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c index 83390f6bab..052aab1003 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -1831,7 +1831,7 @@ textarray_to_strvaluelist(ArrayType *arr) Datum pg_get_object_address(PG_FUNCTION_ARGS) { - char *ttype = TextDatumGetCString(PG_GETARG_TEXT_P(0)); + char *ttype = TextDatumGetCString(PG_GETARG_DATUM(0)); ArrayType *namearr = PG_GETARG_ARRAYTYPE_P(1); ArrayType *argsarr = PG_GETARG_ARRAYTYPE_P(2); int itype; -- 2.40.0