summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-06-06-00-23-19.bpo-40880.fjdzSh.rst2
-rw-r--r--Parser/pegen/pegen.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-06-06-00-23-19.bpo-40880.fjdzSh.rst b/Misc/NEWS.d/next/Core and Builtins/2020-06-06-00-23-19.bpo-40880.fjdzSh.rst
new file mode 100644
index 0000000..ab42f5c
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-06-06-00-23-19.bpo-40880.fjdzSh.rst
@@ -0,0 +1,2 @@
+Fix invalid memory read in the new parser when checking newlines in string
+literals. Patch by Pablo Galindo.
diff --git a/Parser/pegen/pegen.c b/Parser/pegen/pegen.c
index c55ff7e..afe75d7 100644
--- a/Parser/pegen/pegen.c
+++ b/Parser/pegen/pegen.c
@@ -937,8 +937,8 @@ _PyPegen_number_token(Parser *p)
static int // bool
newline_in_string(Parser *p, const char *cur)
{
- for (char c = *cur; cur >= p->tok->buf; c = *--cur) {
- if (c == '\'' || c == '"') {
+ for (const char *c = cur; c >= p->tok->buf; c--) {
+ if (*c == '\'' || *c == '"') {
return 1;
}
}