From: Victor Stinner Date: Mon, 15 Sep 2025 14:23:11 +0000 (+0100) Subject: gh-129813, PEP 782: Init small_buffer in PyBytesWriter_Create() (#138924) X-Git-Tag: v3.15.0a1~365 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7c6efc3a4f41f527ec40b5f5fd0ee1fb7af7c82f;p=thirdparty%2FPython%2Fcpython.git 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. --- 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;