From a5996c4727705f3dd48d0b6d5cacc90392dd58d4 Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Fri, 2 Jan 2026 17:30:52 -0500 Subject: fix memcpy of NULL for zero-length strings --- str.h | 1 + 1 file changed, 1 insertion(+) (limited to 'str.h') diff --git a/str.h b/str.h index 0a22242..b5f2889 100644 --- a/str.h +++ b/str.h @@ -40,6 +40,7 @@ Str str_replace_end(Str s, Str a, Str b, Arena *m); /* conversions */ char *str_to_cstr(Str s, Arena *a) { + if (!s.n) return ""; char *r = new_arr(a, char, s.n + 1); memcpy(r, s.s, s.n); r[s.n] = 0; -- cgit v1.2.3