https://github.com/python/cpython/commit/7c6efc3a4f41f527ec40b5f5fd0ee1fb7af7c82f
commit: 7c6efc3a4f41f527ec40b5f5fd0ee1fb7af7c82f
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2025-09-15T16:23:11+02:00
summary:

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.

files:
M Objects/bytesobject.c

diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 3de57fe4e99e86..ee10f13b7bb04c 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;

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to