]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-129813, PEP 782: Init small_buffer in PyBytesWriter_Create() (#138924)
authorVictor Stinner <vstinner@python.org>
Mon, 15 Sep 2025 14:23:11 +0000 (15:23 +0100)
committerGitHub <noreply@github.com>
Mon, 15 Sep 2025 14:23:11 +0000 (16:23 +0200)
Fill small_buffer with 0xFF byte pattern to detect the usage of
uninitialized bytes in debug build.

Objects/bytesobject.c

index 3de57fe4e99e86d95aacafed65eba28221f1f3d1..ee10f13b7bb04c52b5acec9377414cedd50e80f3 100644 (file)
@@ -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;