Skip to content

Commit 5d1e5c8

Browse files
committed
Check for BuildIndexValueDescription returning NULL in gist_page_items
Per Coverity. BuildIndexValueDescription() cannot actually return NULL in this instance, because it only returns NULL if the user doesn't have the required privileges, and this function can only be used by superuser. But better safe than sorry.
1 parent 15251c0 commit 5d1e5c8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

contrib/pageinspect/gistfuncs.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,20 @@ gist_page_items(PG_FUNCTION_ARGS)
247247
index_deform_tuple(itup, RelationGetDescr(indexRel),
248248
itup_values, itup_isnull);
249249

250-
key_desc = BuildIndexValueDescription(indexRel, itup_values, itup_isnull);
251-
252250
memset(nulls, 0, sizeof(nulls));
253251

254252
values[0] = DatumGetInt16(offset);
255253
values[1] = ItemPointerGetDatum(&itup->t_tid);
256254
values[2] = Int32GetDatum((int) IndexTupleSize(itup));
257-
values[3] = CStringGetTextDatum(key_desc);
255+
256+
key_desc = BuildIndexValueDescription(indexRel, itup_values, itup_isnull);
257+
if (key_desc)
258+
values[3] = CStringGetTextDatum(key_desc);
259+
else
260+
{
261+
values[3] = (Datum) 0;
262+
nulls[3] = true;
263+
}
258264

259265
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
260266
}

0 commit comments

Comments
 (0)