https://github.com/python/cpython/commit/7dec3d7acbb072e0d5cd7357c1ddf12d3c667e8a
commit: 7dec3d7acbb072e0d5cd7357c1ddf12d3c667e8a
branch: 3.12
author: Pablo Galindo Salgado <[email protected]>
committer: pablogsal <[email protected]>
date: 2024-08-23T14:04:25+01:00
summary:

[3.12] gh-123229: Fix valgrind warning by initializing the f-string buffers to 
0 in the tokenizer (GH-123263) (#123265)

(cherry picked from commit adc5190014efcf7b7a4c5dfc9998faa8345527ed)

Signed-off-by: Pablo Galindo <[email protected]>

files:
A Misc/NEWS.d/next/Core and 
Builtins/2024-08-23-13-08-27.gh-issue-123229.aHm-dw.rst
A lel.patch
M Parser/tokenizer.c

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
index 00000000000000..aa9e8d1fa93bf5
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and 
Builtins/2024-08-23-13-08-27.gh-issue-123229.aHm-dw.rst 
@@ -0,0 +1,2 @@
+Fix valgrind warning by initializing the f-string buffers to 0 in the
+tokenizer. Patch by Pablo Galindo
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 3118fb19846578..9e0dee8cc383d6 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;
diff --git a/lel.patch b/lel.patch
new file mode 100644
index 00000000000000..c525a7a00a9d2a
--- /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;

_______________________________________________
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