Skip to content

Commit e955913

Browse files
committed
Better fix for bug #72135
1 parent 7a1aac3 commit e955913

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ext/standard/html.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,11 @@ PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size
14231423
}
14241424
replaced[len] = '\0';
14251425
*newlen = len;
1426+
if(len > INT_MAX) {
1427+
zend_error_noreturn(E_ERROR, "Escaped string is too long");
1428+
efree(replaced);
1429+
return NULL;
1430+
}
14261431

14271432
return replaced;
14281433
}
@@ -1444,10 +1449,6 @@ static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
14441449
}
14451450

14461451
replaced = php_escape_html_entities_ex(str, str_len, &new_len, all, (int) flags, hint_charset, double_encode TSRMLS_CC);
1447-
if (new_len > INT_MAX) {
1448-
efree(replaced);
1449-
RETURN_FALSE;
1450-
}
14511452
RETVAL_STRINGL(replaced, (int)new_len, 0);
14521453
}
14531454
/* }}} */

0 commit comments

Comments
 (0)