]> granicus.if.org Git - php/commitdiff
same for gmp_scan*()
authorAntony Dovgal <tony2001@php.net>
Wed, 18 Apr 2007 20:53:21 +0000 (20:53 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 18 Apr 2007 20:53:21 +0000 (20:53 +0000)
ext/gmp/gmp.c

index 68ce034547235c982476175c225608be9b01c99f..7f386e699770a620ccd596fc39c565d3cb50a5f3 100644 (file)
@@ -1580,6 +1580,11 @@ ZEND_FUNCTION(gmp_scan0)
        FETCH_GMP_ZVAL(gmpnum_a, a_arg);
        convert_to_long_ex(start_arg);
 
+       if (Z_LVAL_PP(start_arg) < 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Starting index must be greater than or equal to zero");
+               RETURN_FALSE;
+       }
+
        RETURN_LONG(mpz_scan0(*gmpnum_a, Z_LVAL_PP(start_arg)));
 }
 /* }}} */
@@ -1597,6 +1602,11 @@ ZEND_FUNCTION(gmp_scan1)
 
        FETCH_GMP_ZVAL(gmpnum_a, a_arg);
        convert_to_long_ex(start_arg);
+       
+       if (Z_LVAL_PP(start_arg) < 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Starting index must be greater than or equal to zero");
+               RETURN_FALSE;
+       }
 
        RETURN_LONG(mpz_scan1(*gmpnum_a, Z_LVAL_PP(start_arg)));
 }