Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7dec3d7

Browse files
authored
[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 adc5190) Signed-off-by: Pablo Galindo <[email protected]>
1 parent 8fe586d commit 7dec3d7

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix valgrind warning by initializing the f-string buffers to 0 in the
2+
tokenizer. Patch by Pablo Galindo

Parser/tokenizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static const char *type_comment_prefix = "# type: ";
6565

6666
static struct tok_state *tok_new(void) {
6767
struct tok_state *tok =
68-
(struct tok_state *)PyMem_Malloc(sizeof(struct tok_state));
68+
(struct tok_state *)PyMem_Calloc(1, sizeof(struct tok_state));
6969
if (tok == NULL)
7070
return NULL;
7171
tok->buf = tok->cur = tok->inp = NULL;

lel.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
2+
index 3118fb19846..9e0dee8cc38 100644
3+
--- a/Parser/tokenizer.c
4+
+++ b/Parser/tokenizer.c
5+
@@ -65,7 +65,7 @@ static const char *type_comment_prefix = "# type: ";
6+
7+
static struct tok_state *tok_new(void) {
8+
struct tok_state *tok =
9+
- (struct tok_state *)PyMem_Malloc(sizeof(struct tok_state));
10+
+ (struct tok_state *)PyMem_Calloc(1, sizeof(struct tok_state));
11+
if (tok == NULL)
12+
return NULL;
13+
tok->buf = tok->cur = tok->inp = NULL;

0 commit comments

Comments
 (0)