core: make sure string is null-terminated in String.from-bytes

This commit is contained in:
hellerve 2020-07-08 21:36:25 +02:00
parent 91b220c051
commit 57a5226a62

View File

@ -183,8 +183,9 @@ Array String_to_MINUS_bytes(const String *s) {
String String_from_MINUS_bytes(Array *a) {
String s;
const char *us = (const char *)a->data;
s = CARP_MALLOC(a->len);
s = CARP_MALLOC(a->len+1);
memcpy(s, us, a->len);
s[a->len = '\0';
return s;
}