diff options
Diffstat (limited to 'userland')
-rw-r--r-- | userland/libc/tb/sv.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/userland/libc/tb/sv.c b/userland/libc/tb/sv.c index 500d041..ad0a61c 100644 --- a/userland/libc/tb/sv.c +++ b/userland/libc/tb/sv.c @@ -135,11 +135,14 @@ struct sv sv_clone(struct sv s) { char *sv_copy_to_c(struct sv s, char *out, size_t buffer_length) { int copy_len = min(s.length + 1, buffer_length); + if(0 == copy_len) { + return NULL; + } if (!out) { out = malloc(copy_len); } memcpy(out, s.s, copy_len - 1); - out[copy_len] = '\0'; + out[copy_len - 1] = '\0'; return out; } |