From 94ff047dd74cd3ad793f68503729a0fe004c10f4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 1 Sep 2025 20:15:02 -0400 Subject: Bugfix for Int.parse() --- CHANGES.md | 2 ++ src/stdlib/integers.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 1c778750..e2f69439 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,8 @@ - Library installation has been cleaned up a bit. - Added a `--format` flag to the `tomo` binary that autoformats your code (currently unstable, do not rely on it just yet). +- Fixed bugs: + - `Int.parse()` had a memory bug. ## v0.3 diff --git a/src/stdlib/integers.c b/src/stdlib/integers.c index 5dc9ac55..863bb42d 100644 --- a/src/stdlib/integers.c +++ b/src/stdlib/integers.c @@ -430,7 +430,7 @@ OptionalInt_t Int$parse(Text_t text, Text_t *remainder) { else if (*end != '\0') return NONE_INT; result = mpz_init_set_str(i, str + 2, 2); } else { - const char *end = str + 2 + strspn(str + 2, "0123456789"); + const char *end = str + strspn(str, "0123456789"); if (remainder) *remainder = Text$from_str(end); else if (*end != '\0') return NONE_INT; result = mpz_init_set_str(i, str, 10); -- cgit v1.2.3