From 7c6efc3a4f41f527ec40b5f5fd0ee1fb7af7c82f Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 15 Sep 2025 15:23:11 +0100 Subject: [PATCH] gh-129813, PEP 782: Init small_buffer in PyBytesWriter_Create() (#138924) Fill small_buffer with 0xFF byte pattern to detect the usage of uninitialized bytes in debug build. --- Objects/bytesobject.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 3de57fe4e99e..ee10f13b7bb0 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -3861,6 +3861,9 @@ byteswriter_create(Py_ssize_t size, int use_bytearray) return NULL; } } +#ifdef Py_DEBUG + memset(writer->small_buffer, 0xff, sizeof(writer->small_buffer)); +#endif writer->obj = NULL; writer->size = 0; writer->use_bytearray = use_bytearray; -- 2.47.3