Skip to content

Commit 59fb29c

Browse files
committed
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.
1 parent f3e122f commit 59fb29c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/backend/utils/adt/array_userfuncs.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2003-2009, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.28 2009/01/01 17:23:48 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.29 2009/06/09 18:15:04 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -520,14 +520,19 @@ array_agg_finalfn(PG_FUNCTION_ARGS)
520520
int dims[1];
521521
int lbs[1];
522522

523+
/*
524+
* Test for null before Asserting we are in right context. This is
525+
* to avoid possible Assert failure in 8.4beta installations, where
526+
* it is possible for users to create NULL constants of type internal.
527+
*/
528+
if (PG_ARGISNULL(0))
529+
PG_RETURN_NULL(); /* returns null iff no input values */
530+
523531
/* cannot be called directly because of internal-type argument */
524532
Assert(fcinfo->context &&
525533
(IsA(fcinfo->context, AggState) ||
526534
IsA(fcinfo->context, WindowAggState)));
527535

528-
if (PG_ARGISNULL(0))
529-
PG_RETURN_NULL(); /* returns null iff no input values */
530-
531536
state = (ArrayBuildState *) PG_GETARG_POINTER(0);
532537

533538
dims[0] = state->nelems;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy