Skip to content

Commit

Permalink
Fix misuse of TextDatumGetCString().
Browse files Browse the repository at this point in the history
"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.
  • Loading branch information
tglsfdc committed Jul 2, 2015
1 parent 10fb48d commit ac50f84
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/backend/catalog/objectaddress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ac50f84

Please sign in to comment.