diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-08-21 08:34:37 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-08-21 08:34:37 +0100 |
commit | e9eaba12d196e0b526fb24f549466ce76168634b (patch) | |
tree | d203e54961b8d0b0eb62f5834bc046a651dc1795 /main.c | |
parent | 7853f637c03e43190c3c15af1b949e71fe915513 (diff) | |
download | alisp-e9eaba12d196e0b526fb24f549466ce76168634b.tar.gz alisp-e9eaba12d196e0b526fb24f549466ce76168634b.tar.bz2 alisp-e9eaba12d196e0b526fb24f549466ce76168634b.zip |
Fix issues with buffer overflow when printing products of sv_copy
Happens because we have no null terminator on the string - rookie
mistake.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -20,8 +20,9 @@ sv_t sv_copy(sv_t old) { - char *newstr = calloc(1, old.size * sizeof(*newstr)); + char *newstr = calloc(1, (old.size + 1) * sizeof(*newstr)); memcpy(newstr, old.data, old.size); + newstr[old.size] = '\0'; return SV(newstr, old.size); } |