[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 adc5190014)

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
Pablo Galindo Salgado 2024-08-23 14:04:25 +01:00 committed by GitHub
parent 8fe586d27a
commit 7dec3d7acb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions

View file

@ -0,0 +1,2 @@
Fix valgrind warning by initializing the f-string buffers to 0 in the
tokenizer. Patch by Pablo Galindo

View 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;

13
lel.patch Normal file
View file

@ -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;