diff options
| author | WormHeamer | 2026-01-02 17:30:52 -0500 |
|---|---|---|
| committer | WormHeamer | 2026-01-02 17:30:52 -0500 |
| commit | a5996c4727705f3dd48d0b6d5cacc90392dd58d4 (patch) | |
| tree | 96bbd53bc7759c0697a5224c81248f0b3b6b1fc5 | |
| parent | 4849d0d9b6e2ff83e1c9f9512671de68f9bf177a (diff) | |
fix memcpy of NULL for zero-length strings
| -rw-r--r-- | str.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -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; |
