Skip to content

Commit c902ad7

Browse files
author
foobar
committed
null terminate the returned string in here too.
1 parent 1ffbcc5 commit c902ad7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/xml/xml.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,10 @@ static XML_Char *xml_utf8_encode(const char *s, int len, int *newlen, const XML_
462462
if (encoder == NULL) {
463463
/* If no encoder function was specified, return the data as-is.
464464
*/
465-
newbuf = emalloc(len);
465+
newbuf = emalloc(len + 1);
466466
memcpy(newbuf, s, len);
467467
*newlen = len;
468+
newbuf[*newlen] = '\0';
468469
return newbuf;
469470
}
470471
/* This is the theoretical max (will never get beyond len * 2 as long

0 commit comments

Comments
 (0)