diff -Nurp orig/ext/standard/string.c new/ext/standard/string.c
--- orig/ext/standard/string.c	2007-02-21 08:44:35.000000000 +0100
+++ new/ext/standard/string.c	2007-02-21 08:45:14.000000000 +0100
@@ -3044,7 +3044,7 @@ PHPAPI int php_char_to_str_ex(char *str,
 	}
 	
 	Z_STRLEN_P(result) = len + (char_count * (to_len - 1));
-	Z_STRVAL_P(result) = target = emalloc(Z_STRLEN_P(result) + 1);
+	Z_STRVAL_P(result) = target = safe_emalloc(char_count, to_len, len + 1);
 	Z_TYPE_P(result) = IS_STRING;
 
 	if (case_sensitivity) {
