ext__standard__html.c.diff   [plain text]


--- ext/standard/html.c.orig	2006/02/25 21:33:06	1.63.2.23.2.2
+++ ext/standard/html.c	2006/11/01 01:56:46	1.63.2.23.2.3
@@ -878,7 +878,7 @@
 
 		matches_map = 0;
 
-		if (len + 9 > maxlen)
+		if (len + 16 > maxlen)
 			replaced = erealloc (replaced, maxlen += 128);
 
 		if (all) {
@@ -903,9 +903,15 @@
 			}
 
 			if (matches_map) {
+				int l = strlen(rep);
+				/* increase the buffer size */
+				if (len + 2 + l >= maxlen) {
+					replaced = erealloc(replaced, maxlen += 128);
+				}
+
 				replaced[len++] = '&';
 				strcpy(replaced + len, rep);
-				len += strlen(rep);
+				len += l;
 				replaced[len++] = ';';
 			}
 		}