From c902ad74f0ef5edc2b780e087ef419acba5d15b6 Mon Sep 17 00:00:00 2001 From: foobar Date: Sat, 18 Aug 2001 23:43:04 +0000 Subject: null terminate the returned string in here too. --- ext/xml/xml.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ext/xml/xml.c') diff --git a/ext/xml/xml.c b/ext/xml/xml.c index a7e25ae2ea..7c187223e4 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -462,9 +462,10 @@ static XML_Char *xml_utf8_encode(const char *s, int len, int *newlen, const XML_ if (encoder == NULL) { /* If no encoder function was specified, return the data as-is. */ - newbuf = emalloc(len); + newbuf = emalloc(len + 1); memcpy(newbuf, s, len); *newlen = len; + newbuf[*newlen] = '\0'; return newbuf; } /* This is the theoretical max (will never get beyond len * 2 as long -- cgit v1.2.1