summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--str.h1
1 files changed, 1 insertions, 0 deletions
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;