From e658f2b86a3da4d26f61054edc5c912f6cb8ad4d Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Fri, 24 Jan 2025 13:42:31 +0300 Subject: [PATCH] address review: comment --- Modules/_decimal/_decimal.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index d04ebe036c325a..b9abd8bd2e7a53 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -3689,6 +3689,11 @@ dec_as_long(PyObject *dec, PyObject *context, int round) assert(layout->digit_size == 2 || layout->digit_size == 4); uint32_t base = (uint32_t)1 << layout->bits_per_digit; + /* We use a temporary buffer for digits for now, as for nonzero rdata + mpd_qexport_u32/u16() require either space "allocated by one of + libmpdec’s allocation functions" or "rlen MUST be correct" (to avoid + reallocation). This can be further optimized by using rlen from + mpd_sizeinbase(). See gh-127925. */ void *tmp_digits = NULL; size_t n;