diff options
author | Anton Kling <anton@kling.gg> | 2024-04-18 18:18:53 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-04-18 18:18:53 +0200 |
commit | 5606d715128edaf1830c895fd3619f1f1af67d56 (patch) | |
tree | 5de1d53e44657ade9f0accaa681aae1489f475a8 /userland | |
parent | 8868c3184a0cebefbf5dad66a0526496f4607df8 (diff) |
LibC: Fix bug in sv_clone
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; } |