Skip to content

Commit 2f9c02c

Browse files
authored
Fix sanitizer failure due to attach_chunk (#8315)
Fix use-after-poison errors caused by ts_constraint_find_matching() returning a pointer to memory that is not valid anymore. Disable-check: force-changelog-file
1 parent 4aa5b61 commit 2f9c02c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/constraint.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ ts_constraint_find_matching(HeapTuple ht_tup, Relation chunk_rel)
109109
{
110110
if (ts_indexing_compare(ht_con->conindid, chunk_con->conindid))
111111
{
112-
result = chunk_con;
112+
/*
113+
* pfree'ing this form is up to the caller. It is not expected to
114+
* consume a lot of memory, as only one form is allocated per
115+
* constraint.
116+
*/
117+
result = (Form_pg_constraint) palloc(sizeof(FormData_pg_constraint));
118+
memcpy(result, chunk_con, sizeof(FormData_pg_constraint));
113119
break;
114120
}
115121
}

0 commit comments

Comments
 (0)