added \0 to try to control the utf8strings

This commit is contained in:
gilteixeira 2023-03-14 15:17:46 +00:00
parent dd46251048
commit 8d4a4a0419
1 changed files with 4 additions and 3 deletions

View File

@ -23,9 +23,10 @@
static UTF8String_t *create_utf8_from_string(const char* string, size_t length) { static UTF8String_t *create_utf8_from_string(const char* string, size_t length) {
UTF8String_t *utf8_string = calloc(1, sizeof(UTF8String_t)); UTF8String_t *utf8_string = calloc(1, sizeof(UTF8String_t));
utf8_string->buf = calloc(length, sizeof(uint8_t)); utf8_string->buf = calloc(length+1, sizeof(uint8_t));
utf8_string->size = length; utf8_string->size = length+1;
memcpy(utf8_string->buf, string, length); memcpy(utf8_string->buf, string, length+1);
utf8_string->buf[length] = '\0';
return utf8_string; return utf8_string;
} }