diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-11-19 03:00:09 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-11-19 03:00:09 +0000 |
commit | 8ef289dba12f16f3692c235863a887672499a5d9 (patch) | |
tree | 819abde06463716dbbf505c444a69ec6858efe6a /contrib/intarray/_intbig_gist.c | |
parent | 25c00833cb694bea1c4fb3caeccbc9a1fb72d6f8 (diff) | |
download | postgresql-8ef289dba12f16f3692c235863a887672499a5d9.tar.gz postgresql-8ef289dba12f16f3692c235863a887672499a5d9.zip |
Defend against nulls-in-arrays in contrib/intarray. I may have put in
more tests than strictly necessary, but did not feel like tracing call
paths in detail ...
Diffstat (limited to 'contrib/intarray/_intbig_gist.c')
-rw-r--r-- | contrib/intarray/_intbig_gist.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c index 237281aec5b..0064e450ddb 100644 --- a/contrib/intarray/_intbig_gist.c +++ b/contrib/intarray/_intbig_gist.c @@ -66,6 +66,8 @@ _intbig_overlap(GISTTYPE * a, ArrayType *b) int num = ARRNELEMS(b); int4 *ptr = ARRPTR(b); + CHECKARRVALID(b); + while (num--) { if (GETBIT(GETSIGN(a), HASHVAL(*ptr))) @@ -82,6 +84,8 @@ _intbig_contains(GISTTYPE * a, ArrayType *b) int num = ARRNELEMS(b); int4 *ptr = ARRPTR(b); + CHECKARRVALID(b); + while (num--) { if (!GETBIT(GETSIGN(a), HASHVAL(*ptr))) @@ -136,10 +140,17 @@ g_intbig_compress(PG_FUNCTION_ARGS) int num; GISTTYPE *res = (GISTTYPE *) palloc(CALCGTSIZE(0)); - ARRISVOID(in); - - ptr = ARRPTR(in); - num = ARRNELEMS(in); + CHECKARRVALID(in); + if (ARRISVOID(in)) + { + ptr = NULL; + num = 0; + } + else + { + ptr = ARRPTR(in); + num = ARRNELEMS(in); + } memset(res, 0, CALCGTSIZE(0)); res->len = CALCGTSIZE(0); @@ -492,6 +503,7 @@ g_intbig_consistent(PG_FUNCTION_ARGS) } /* XXX what about toasted input? */ + CHECKARRVALID(query); if (ARRISVOID(query)) return FALSE; @@ -510,6 +522,8 @@ g_intbig_consistent(PG_FUNCTION_ARGS) BITVECP dq, de; + CHECKARRVALID(query); + memset(qp, 0, sizeof(BITVEC)); while (num--) @@ -546,6 +560,8 @@ g_intbig_consistent(PG_FUNCTION_ARGS) BITVECP dq, de; + CHECKARRVALID(query); + memset(qp, 0, sizeof(BITVEC)); while (num--) |