aboutsummaryrefslogtreecommitdiff
path: root/src/parse.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-24 16:21:08 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-24 16:21:08 -0400
commit764bdd108057669dd32874619932dbf4f06451d7 (patch)
treee54adeca1df23458d58603d52dae297ce88f6d5c /src/parse.c
parentec732ab7d04d50a282503e8773be92768ea5918e (diff)
Bugfix for parsing escapes
Diffstat (limited to 'src/parse.c')
-rw-r--r--src/parse.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/parse.c b/src/parse.c
index 325131e5..dabb3729 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -231,14 +231,14 @@ static const char *unescape(parse_ctx_t *ctx, const char **out) {
*endpos = endptr;
return GC_strndup((char*)buf, bufsize);
} else if (escape[1] == 'x' && escape[2] && escape[3]) {
- // ASCII 2-digit hex
- char *endptr = NULL;
- char c = (char)strtol(escape+2, &endptr, 16);
+ // ASCII 2-digit hex
+ char buf[] = {escape[2], escape[3], 0};
+ char c = (char)strtol(buf, NULL, 16);
*endpos = escape + 4;
return GC_strndup(&c, 1);
} else if ('0' <= escape[1] && escape[1] <= '7' && '0' <= escape[2] && escape[2] <= '7' && '0' <= escape[3] && escape[3] <= '7') {
- char *endptr = NULL;
- char c = (char)strtol(escape+1, &endptr, 8);
+ char buf[] = {escape[1], escape[2], escape[3], 0};
+ char c = (char)strtol(buf, NULL, 8);
*endpos = escape + 4;
return GC_strndup(&c, 1);
} else {