mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-05 04:44:12 +03:00
core: make sure string is null-terminated in String.from-bytes
This commit is contained in:
parent
91b220c051
commit
57a5226a62
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user