Skip to content

Commit e63ce9e

Browse files
Ensure that slots are zeroed before use
The previous coding relied on the memory for the slots being zeroed elsewhere, which while it was true in this case is not an contract which is guaranteed to hold. Explicitly clear the tts_isnull array to ensure that the slots are filled from a known state. Backpatch to v14 where the catalog multi-inserts were introduced. Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CAJ7c6TP0AowkUgNL6zcAK-s5HYsVHVBRWfu69FRubPpfwZGM9A@mail.gmail.com Backpatch-through: 14
1 parent 8af09da commit e63ce9e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/backend/catalog/heap.c

+3
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,9 @@ InsertPgAttributeTuples(Relation pg_attribute_rel,
764764

765765
ExecClearTuple(slot[slotCount]);
766766

767+
memset(slot[slotCount]->tts_isnull, false,
768+
slot[slotCount]->tts_tupleDescriptor->natts * sizeof(bool));
769+
767770
if (new_rel_oid != InvalidOid)
768771
slot[slotCount]->tts_values[Anum_pg_attribute_attrelid - 1] = ObjectIdGetDatum(new_rel_oid);
769772
else

src/backend/catalog/pg_shdepend.c

+3
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,9 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId)
903903

904904
ExecClearTuple(slot[slot_stored_count]);
905905

906+
memset(slot[slot_stored_count]->tts_isnull, false,
907+
slot[slot_stored_count]->tts_tupleDescriptor->natts * sizeof(bool));
908+
906909
shdep = (Form_pg_shdepend) GETSTRUCT(tup);
907910

908911
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(newDbId);

0 commit comments

Comments
 (0)