]> granicus.if.org Git - php/commitdiff
Improve parameter parsing code
authorIlia Alshanetsky <iliaa@php.net>
Fri, 6 Mar 2009 15:48:30 +0000 (15:48 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 6 Mar 2009 15:48:30 +0000 (15:48 +0000)
ext/mbstring/mbstring.c

index 5c50fa636d0e993e4229b0d884fdac912b96e202..2474c17d506746d21f139b6bcfb796822071be3a 100644 (file)
@@ -2279,7 +2279,7 @@ PHP_FUNCTION(mb_strrpos)
        mbfl_string haystack, needle;
        char *enc_name = NULL;
        int enc_name_len;
-       zval **zoffset;
+       zval **zoffset = NULL;
        long offset = 0, str_flg;
        char *enc_name2 = NULL;
        int enc_name_len2;
@@ -2295,7 +2295,7 @@ PHP_FUNCTION(mb_strrpos)
                RETURN_FALSE;
        }
 
-       if(ZEND_NUM_ARGS() >= 3) {
+       if (zoffset) {
                if (Z_TYPE_PP(zoffset) == IS_STRING) {
                        enc_name2     = Z_STRVAL_PP(zoffset);
                        enc_name_len2 = Z_STRLEN_PP(zoffset);
@@ -2323,9 +2323,9 @@ PHP_FUNCTION(mb_strrpos)
                                }
                        }
 
-                       if(str_flg) {
-                                       convert_to_long_ex(zoffset);
-                                       offset   = Z_LVAL_PP(zoffset);
+                       if (str_flg) {
+                               convert_to_long_ex(zoffset);
+                               offset   = Z_LVAL_PP(zoffset);
                        } else {
                                enc_name     = enc_name2;
                                enc_name_len = enc_name_len2;