From 828dd435725ea315abd2ea9875325ee3b17041a9 Mon Sep 17 00:00:00 2001 From: "Nathan P. Reiner" Date: Thu, 15 Dec 2022 18:20:33 +0100 Subject: did this while lecture (builtins, parsing, exec and env by stdlib) --- lib/cstr/cstr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/cstr') diff --git a/lib/cstr/cstr.c b/lib/cstr/cstr.c index fcb91f4..f464cf3 100644 --- a/lib/cstr/cstr.c +++ b/lib/cstr/cstr.c @@ -264,7 +264,7 @@ u8 previous_utf8(const char **c) void u64_to_cstr(u64 n, char *cstr, u64 length) { char *p = cstr + length - 1; - u64 d; + u64 d = 0; int i = 0; for (;n && i < length; ++i) { @@ -272,7 +272,7 @@ void u64_to_cstr(u64 n, char *cstr, u64 length) n /= 10; } - d = p - cstr; + d = p - cstr + 1; for (i = 0; i < length - d; ++i) cstr[i] = cstr[i + d]; -- cgit v1.2.3-70-g09d2