]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-123229: Fix valgrind warning by initializing the f-string buffers to 0...
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Fri, 23 Aug 2024 13:04:25 +0000 (14:04 +0100)
committerGitHub <noreply@github.com>
Fri, 23 Aug 2024 13:04:25 +0000 (14:04 +0100)
(cherry picked from commit adc5190014efcf7b7a4c5dfc9998faa8345527ed)

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Misc/NEWS.d/next/Core and Builtins/2024-08-23-13-08-27.gh-issue-123229.aHm-dw.rst [new file with mode: 0644]
Parser/tokenizer.c
lel.patch [new file with mode: 0644]

diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-08-23-13-08-27.gh-issue-123229.aHm-dw.rst b/Misc/NEWS.d/next/Core and Builtins/2024-08-23-13-08-27.gh-issue-123229.aHm-dw.rst
new file mode 100644 (file)
index 0000000..aa9e8d1
--- /dev/null
@@ -0,0 +1,2 @@
+Fix valgrind warning by initializing the f-string buffers to 0 in the
+tokenizer. Patch by Pablo Galindo
index 3118fb198465781154e545b84852fdb45c22d2a1..9e0dee8cc383d6bdc769f14b1b98b732db5c815c 100644 (file)
@@ -65,7 +65,7 @@ static const char *type_comment_prefix = "# type: ";
 
 static struct tok_state *tok_new(void) {
   struct tok_state *tok =
-      (struct tok_state *)PyMem_Malloc(sizeof(struct tok_state));
+      (struct tok_state *)PyMem_Calloc(1, sizeof(struct tok_state));
   if (tok == NULL)
     return NULL;
   tok->buf = tok->cur = tok->inp = NULL;
diff --git a/lel.patch b/lel.patch
new file mode 100644 (file)
index 0000000..c525a7a
--- /dev/null
+++ b/lel.patch
@@ -0,0 +1,13 @@
+diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
+index 3118fb19846..9e0dee8cc38 100644
+--- a/Parser/tokenizer.c
++++ b/Parser/tokenizer.c
+@@ -65,7 +65,7 @@ static const char *type_comment_prefix = "# type: ";
+
+ static struct tok_state *tok_new(void) {
+   struct tok_state *tok =
+-      (struct tok_state *)PyMem_Malloc(sizeof(struct tok_state));
++      (struct tok_state *)PyMem_Calloc(1, sizeof(struct tok_state));
+   if (tok == NULL)
+     return NULL;
+   tok->buf = tok->cur = tok->inp = NULL;