diff --git a/src/common/gamecode/xmlreport.c b/src/common/gamecode/xmlreport.c index e8d925eb4..49d5eaf4d 100644 --- a/src/common/gamecode/xmlreport.c +++ b/src/common/gamecode/xmlreport.c @@ -89,9 +89,10 @@ xml_s(const char * str) const char * inbuf = str; unsigned char * outbuf = buffer; size_t inbytes = strlen(str)+1; - size_t outbytes = sizeof(buffer); + size_t outbytes = sizeof(buffer) - 1; unicode_latin1_to_utf8(outbuf, &outbytes, (const xmlChar *)inbuf, &inbytes); + buffer[outbytes] = 0; return buffer; } diff --git a/src/common/modules/autoseed.c b/src/common/modules/autoseed.c index f374eb7d1..091606649 100644 --- a/src/common/modules/autoseed.c +++ b/src/common/modules/autoseed.c @@ -244,9 +244,10 @@ read_newfactions(const char * filename) nf->race = findrace(race, default_locale); if (nf->race==NULL) { char buffer[32]; - size_t outbytes = sizeof(buffer); + size_t outbytes = sizeof(buffer) - 1; size_t inbytes = strlen(race); unicode_latin1_to_utf8((unsigned char *)buffer, &outbytes, (const unsigned char *)race, &inbytes); + buffer[outbytes] = 0; nf->race = findrace(buffer, default_locale); if (nf->race==NULL) { log_error(("new faction has unknown race '%s'.\n", race));