Include a null byte at the end of the string, length doesn't include it

Fixes #2758
This commit is contained in:
Eric Soroos 2017-11-02 12:56:08 +00:00
parent b0b2009c58
commit 7e484eba77

View File

@ -2212,7 +2212,7 @@ void _font_text_asBytes(PyObject* encoded_string, unsigned char** text){
PyBytes_AsStringAndSize(encoded_string, &buffer, &len); PyBytes_AsStringAndSize(encoded_string, &buffer, &len);
} }
*text = calloc(len,1); *text = calloc(len+1,1);
if (*text) { if (*text) {
memcpy(*text, buffer, len); memcpy(*text, buffer, len);
} }
@ -2230,7 +2230,7 @@ void _font_text_asBytes(PyObject* encoded_string, unsigned char** text){
PyString_AsStringAndSize(encoded_string, &buffer, &len); PyString_AsStringAndSize(encoded_string, &buffer, &len);
*text = calloc(len,1); *text = calloc(len,1);
if (*text) { if (*text) {
memcpy(*text, buffer, len); memcpy(*text, buffer, len+1);
} }
return; return;
} }