From 759e2be23ade06659c9e2d152796d226bfc02b83 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 13 Nov 2026 11:58:18 +0100 Subject: [PATCH 4/5] Fixes for alloc_size attribute [numeric] "Short" Numeric values are now allocated with at least the size of the struct, so that accessing fields through the struct stays within the allocation. --- src/backend/utils/adt/numeric.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 7deea2046f1..9f0913e2326 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -7620,7 +7620,11 @@ make_result_safe(const NumericVar *var, Node *escontext) sign == NUMERIC_NINF)) elog(ERROR, "invalid numeric sign value 0x%x", sign); - result = (Numeric) palloc(NUMERIC_HDRSZ_SHORT); + /* + * We must allocate at least the full struct size, even though the + * datum only uses NUMERIC_HDRSZ_SHORT bytes. + */ + result = (Numeric) palloc(sizeof(struct NumericData)); SET_VARSIZE(result, NUMERIC_HDRSZ_SHORT); result->choice.n_header = sign; -- 2.56.0