From 49ad32d5d99cb4a79bf648c0b7f9eca19b54cf1d Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Fri, 22 May 2015 18:36:48 -0400
Subject: [PATCH] Fix recently-introduced crash in array_contain_compare().

Silly oversight in commit 1dc5ebc9077ab742079ce5dac9a6664248d42916:
when array2 is an expanded array, it might have array2->xpn.dnulls equal
to NULL, indicating the array is known null-free.  The code wasn't
expecting that, because it formerly always used deconstruct_array() which
always delivers a nulls array.

Per bug #13334 from Regina Obe.
---
 src/backend/utils/adt/arrayfuncs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 82d79977d7a..42cdbc7d6e0 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -4110,7 +4110,7 @@ array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation,
 		for (j = 0; j < nelems2; j++)
 		{
 			Datum		elt2 = values2[j];
-			bool		isnull2 = nulls2[j];
+			bool		isnull2 = nulls2 ? nulls2[j] : false;
 			bool		oprresult;
 
 			if (isnull2)
-- 
GitLab