shithub: femtolisp

Download patch

ref: 19887e156a7fe98c224793b4f95f42035e604645
parent: 494e560b72f5132a3b88db7e28b3e8d872fa55cc
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Mon Mar 27 16:57:22 EDT 2023

disallow invalid escape sequences (modified patch from Julia)

--- a/read.c
+++ b/read.c
@@ -552,7 +552,12 @@
                     i += u8_wc_toutf8(&buf[i], wc);
             }
             else {
-                buf[i++] = read_escape_control_char((char)c);
+                char esc = read_escape_control_char((char)c);
+                if (esc == (char)c && !strchr("\\'\"`", esc)) {
+                    free(buf);
+                    lerrorf(ParseError, "read: invalid escape sequence: \\%c", (char)c);
+                }
+                buf[i++] = esc;
             }
         }
         else {