summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2021-06-12 17:53:49 (GMT)
committerGitHub <noreply@github.com>2021-06-12 17:53:49 (GMT)
commita342cc5891dbd8a08d40e9444f2e2c9e93258721 (patch)
tree3d5a7116001f14dbe55b9526f52eea83860e7fed /Parser
parent9d8dd8f08aae4ad6e73a9322a4e9dee965afebbc (diff)
downloadcpython-a342cc5891dbd8a08d40e9444f2e2c9e93258721.zip
cpython-a342cc5891dbd8a08d40e9444f2e2c9e93258721.tar.gz
cpython-a342cc5891dbd8a08d40e9444f2e2c9e93258721.tar.bz2
bpo-44396: Update multi-line-start location when reallocating tokenizer buffers (GH-26676)
Automerge-Triggered-By: GH:pablogsal
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 6002f3e..be9b13e 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -372,6 +372,8 @@ tok_reserve_buf(struct tok_state *tok, Py_ssize_t size)
if (newsize > tok->end - tok->buf) {
char *newbuf = tok->buf;
Py_ssize_t start = tok->start == NULL ? -1 : tok->start - tok->buf;
+ Py_ssize_t line_start = tok->start == NULL ? -1 : tok->line_start - tok->buf;
+ Py_ssize_t multi_line_start = tok->multi_line_start - tok->buf;
newbuf = (char *)PyMem_Realloc(newbuf, newsize);
if (newbuf == NULL) {
tok->done = E_NOMEM;
@@ -382,6 +384,8 @@ tok_reserve_buf(struct tok_state *tok, Py_ssize_t size)
tok->inp = tok->buf + oldsize;
tok->end = tok->buf + newsize;
tok->start = start < 0 ? NULL : tok->buf + start;
+ tok->line_start = line_start < 0 ? NULL : tok->buf + line_start;
+ tok->multi_line_start = multi_line_start < 0 ? NULL : tok->buf + multi_line_start;
}
return 1;
}
@@ -1883,6 +1887,7 @@ tok_get(struct tok_state *tok, const char **p_start, const char **p_end)
while (end_quote_size != quote_size) {
c = tok_nextc(tok);
if (c == EOF || (quote_size == 1 && c == '\n')) {
+ assert(tok->multi_line_start != NULL);
// shift the tok_state's location into
// the start of string, and report the error
// from the initial quote character