diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-06-09 18:15:04 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-06-09 18:15:04 +0000 |
commit | 59fb29cac64cb77ad6fd0b0b03160a62d1a2df11 (patch) | |
tree | f18b4f82b9d658bb9c5e9c2fe015ca47599d23a5 /src/backend/utils/adt/array_userfuncs.c | |
parent | f3e122fcdf68fcc28c0d03971e19c318fe3bc405 (diff) | |
download | postgresql-59fb29cac64cb77ad6fd0b0b03160a62d1a2df11.tar.gz postgresql-59fb29cac64cb77ad6fd0b0b03160a62d1a2df11.zip |
Switch order of tests to avoid possible Assert failure for
"array_agg_finalfn(null)". We should modify pg_proc entries to prevent this
query from being accepted, but let's just make the function itself secure too.
Per my note of today.
Diffstat (limited to 'src/backend/utils/adt/array_userfuncs.c')
-rw-r--r-- | src/backend/utils/adt/array_userfuncs.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c index 09fa9508730..b43ad389937 100644 --- a/src/backend/utils/adt/array_userfuncs.c +++ b/src/backend/utils/adt/array_userfuncs.c @@ -6,7 +6,7 @@ * Copyright (c) 2003-2009, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.28 2009/01/01 17:23:48 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.29 2009/06/09 18:15:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -520,14 +520,19 @@ array_agg_finalfn(PG_FUNCTION_ARGS) int dims[1]; int lbs[1]; + /* + * Test for null before Asserting we are in right context. This is + * to avoid possible Assert failure in 8.4beta installations, where + * it is possible for users to create NULL constants of type internal. + */ + if (PG_ARGISNULL(0)) + PG_RETURN_NULL(); /* returns null iff no input values */ + /* cannot be called directly because of internal-type argument */ Assert(fcinfo->context && (IsA(fcinfo->context, AggState) || IsA(fcinfo->context, WindowAggState))); - if (PG_ARGISNULL(0)) - PG_RETURN_NULL(); /* returns null iff no input values */ - state = (ArrayBuildState *) PG_GETARG_POINTER(0); dims[0] = state->nelems; |