cvs: php4 /ext/xml xml.c
| From: | Thies C. Arntzen | Date: | Mon, 09 Jul 2001 06:49:35 +0000 |
| Subject: | cvs: php4 /ext/xml xml.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-6124@lists.php.net to get a copy of this message | ||
thies Mon Jul 9 02:49:35 2001 EDT
Modified files:
/php4/ext/xml xml.c
Log:
xml_utf8_encode: make sure the returned data is zero-terminated
Index: php4/ext/xml/xml.c
diff -u php4/ext/xml/xml.c:1.79 php4/ext/xml/xml.c:1.80
--- php4/ext/xml/xml.c:1.79 Wed Jun 6 09:05:52 2001
+++ php4/ext/xml/xml.c Mon Jul 9 02:49:34 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xml.c,v 1.79 2001/06/06 13:05:52 rasmus Exp $ */
+/* $Id: xml.c,v 1.80 2001/07/09 06:49:34 thies Exp $ */
#define IS_EXT_MODULE
#ifdef HAVE_CONFIG_H
@@ -492,7 +492,7 @@
}
/* This is the theoretical max (will never get beyond len * 2 as long
* as we are converting from single-byte characters, though) */
- newbuf = emalloc(len * 4);
+ newbuf = emalloc(len * 4 + 1);
while (pos > 0) {
c = encoder ? encoder((unsigned char)(*s)) : (unsigned short)(*s);
if (c < 0x80) {
@@ -513,9 +513,8 @@
pos--;
s++;
}
- if (*newlen < len * 4) {
- newbuf = erealloc(newbuf, *newlen);
- }
+ newbuf[*newlen] = 0;
+ newbuf = erealloc(newbuf, (*newlen)+1);
return newbuf;
}
/* }}} */