Skip to content

Commit 1ed1f80

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 a6a0ae1 commit 1ed1f80

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/backend/catalog/heap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,9 @@ InsertPgAttributeTuples(Relation pg_attribute_rel,
766766

767767
ExecClearTuple(slot[slotCount]);
768768

769+
memset(slot[slotCount]->tts_isnull, false,
770+
slot[slotCount]->tts_tupleDescriptor->natts * sizeof(bool));
771+
769772
if (new_rel_oid != InvalidOid)
770773
slot[slotCount]->tts_values[Anum_pg_attribute_attrelid - 1] = ObjectIdGetDatum(new_rel_oid);
771774
else

src/backend/catalog/pg_shdepend.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,9 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId)
907907

908908
ExecClearTuple(slot[slot_stored_count]);
909909

910+
memset(slot[slot_stored_count]->tts_isnull, false,
911+
slot[slot_stored_count]->tts_tupleDescriptor->natts * sizeof(bool));
912+
910913
shdep = (Form_pg_shdepend) GETSTRUCT(tup);
911914

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

0 commit comments

Comments
 (0)