Patch substr_compare_optlen for Unknown/Other Function Bug #55451
Patch version 2011-08-18 15:56 UTC
Return to Bug #55451 |
Download this patch
Patch Revisions:
Developer: datibbaw@php.net
Index: string.c
===================================================================
--- string.c (revision 315071)
+++ string.c (working copy)
@@ -5271,17 +5271,25 @@
{
char *s1, *s2;
int s1_len, s2_len;
- long offset, len=0;
+ long offset, len = 0;
zend_bool cs=0;
uint cmp_len;
+ zval **zlen = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl|lb", &s1, &s1_len, &s2, &s2_len, &offset, &len, &cs) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl|Zb", &s1, &s1_len, &s2, &s2_len, &offset, &zlen, &cs) == FAILURE) {
RETURN_FALSE;
}
- if (ZEND_NUM_ARGS() >= 4 && len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length must be greater than zero");
- RETURN_FALSE;
+ if (ZEND_NUM_ARGS() >= 4 && Z_TYPE_PP(zlen) != IS_NULL) {
+ if (Z_ISREF_PP(zlen)) {
+ SEPARATE_ZVAL(zlen);
+ }
+ convert_to_long_ex(zlen);
+ len = Z_LVAL_PP(zlen);
+ if (len <= 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length must be greater than zero");
+ RETURN_FALSE;
+ }
}
if (offset < 0) {
|