summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2019-02-01 10:36:02 +0900
committerMichael Paquier <michael@paquier.xyz>2019-02-01 10:36:02 +0900
commit05d24cf7ca7aae4f6842dfbd0962a9d04511ba78 (patch)
tree6d02ab64fb347d3d0700333a13afd025d856b995
parent452253eae95a3dd36b52606c91844af5f647d7fa (diff)
Fix use of dangling pointer in heap_delete() when logging replica identity
When logging the replica identity of a deleted tuple, XLOG_HEAP_DELETE records include references of the old tuple. Its data is stored in an intermediate variable used to register this information for the WAL record, but this variable gets away from the stack when the record gets actually inserted. Spotted by clang's AddressSanitizer. Author: Stas Kelvish Discussion: https://postgr.es/m/085C8825-AD86-4E93-AF80-E26CDF03D1EA@postgrespro.ru Backpatch-through: 9.4
-rw-r--r--src/backend/access/heap/heapam.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index e873e1617e4..6a10d9defbf 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -2938,6 +2938,7 @@ l1:
if (RelationNeedsWAL(relation))
{
xl_heap_delete xlrec;
+ xl_heap_header xlhdr;
XLogRecPtr recptr;
XLogRecData rdata[4];
@@ -2967,8 +2968,6 @@ l1:
*/
if (old_key_tuple != NULL)
{
- xl_heap_header xlhdr;
-
xlhdr.t_infomask2 = old_key_tuple->t_data->t_infomask2;
xlhdr.t_infomask = old_key_tuple->t_data->t_infomask;
xlhdr.t_hoff = old_key_tuple->t_data->t_hoff;