fix_datum_serialization_v4.patch
application/octet-stream
Filename: fix_datum_serialization_v4.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
Series: patch v4
| File | + | − |
|---|---|---|
| src/backend/utils/adt/datum.c | 12 | 1 |
diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c
index f02a5e7..4957682 100644
--- a/src/backend/utils/adt/datum.c
+++ b/src/backend/utils/adt/datum.c
@@ -338,8 +338,19 @@ datumSerialize(Datum value, bool isnull, bool typByVal, int typLen,
}
else if (eoh)
{
- EOH_flatten_into(eoh, (void *) *start_address, header);
+ char *tmp;
+
+ /*
+ * EOH_flatten_into expects the target address to be maxaligned,
+ * so we can't store directly to *start_address.
+ */
+ tmp = (char *) palloc(header);
+ EOH_flatten_into(eoh, (void *) tmp, header);
+ memcpy(*start_address, tmp, header);
*start_address += header;
+
+ /* be tidy. */
+ pfree(tmp);
}
else
{