diff options
| author | Andrew Chambers <[email protected]> | 2021-10-08 15:08:08 +1300 |
|---|---|---|
| committer | Andrew Chambers <[email protected]> | 2021-10-08 15:08:08 +1300 |
| commit | e8fdb5043d8de0921d06a054b780c8254145e11d (patch) | |
| tree | 789e0d96bc756ef5be6a356404ce5dece5f87014 | |
| parent | ab551328e2542f65b1fbee9df479c5b4957c8c9f (diff) | |
More error checking in hex literals.
| -rw-r--r-- | main.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -146,6 +146,7 @@ static Parsev *dupv(Parsev *p) { static String decodestring(char *s) { int i; + char *end; size_t len = 0; size_t cap = 0; uint8_t *data = NULL; @@ -156,13 +157,16 @@ static String decodestring(char *s) { if (!*s) { lfatal("bad escape in string"); } else if (*s >= '0' && *s <= '7') { - char *end; c = strtoul(s, &end, 8); s += 3; if (s != end) lfatal("invalid octal sequence"); } else if (*s == 'x') { - lfatal("TODO hex escape"); + s++; + c = strtoul(s, &end, 16); + if (s == end) + lfatal("invalid hex sequence"); + s = end; } else { c = *s; s++; |
