* bpo-40880: Fix invalid read in newline_in_string in pegen.c
* Update Parser/pegen/pegen.c
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
* Add NEWS entry
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
--- /dev/null
+Fix invalid memory read in the new parser when checking newlines in string
+literals. Patch by Pablo Galindo.
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;
}
}