summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2023-06-13 15:18:11 (GMT)
committerGitHub <noreply@github.com>2023-06-13 15:18:11 (GMT)
commitabfbab6415fb029e7dca19ecc8d29a13da37bf71 (patch)
tree2f4e113ed9c8c7c9e6cd49e246c5d415df2a6810 /Parser
parentd0f1afd9425e28409fbf535bb7d43472bfcffcef (diff)
downloadcpython-abfbab6415fb029e7dca19ecc8d29a13da37bf71.zip
cpython-abfbab6415fb029e7dca19ecc8d29a13da37bf71.tar.gz
cpython-abfbab6415fb029e7dca19ecc8d29a13da37bf71.tar.bz2
gh-105718: Fix buffer allocation in tokenizer with readline (#105728)
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c4
-rw-r--r--Parser/tokenizer.h2
2 files changed, 1 insertions, 5 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index bf6bfd9..5d01b8e 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -1106,11 +1106,7 @@ tok_readline_string(struct tok_state* tok) {
tok->inp += buflen;
*tok->inp = '\0';
- if (tok->start == NULL) {
- tok->buf = tok->cur;
- }
tok->line_start = tok->cur;
-
Py_DECREF(line);
return 1;
error:
diff --git a/Parser/tokenizer.h b/Parser/tokenizer.h
index 16e919a..cb44845 100644
--- a/Parser/tokenizer.h
+++ b/Parser/tokenizer.h
@@ -68,7 +68,7 @@ typedef struct _tokenizer_mode {
struct tok_state {
/* Input state; buf <= cur <= inp <= end */
/* NB an entire line is held in the buffer */
- char *buf; /* Input buffer, or NULL; malloc'ed if fp != NULL */
+ char *buf; /* Input buffer, or NULL; malloc'ed if fp != NULL or readline != NULL */
char *cur; /* Next character in buffer */
char *inp; /* End of data in buffer */
int fp_interactive; /* If the file descriptor is interactive */