]> granicus.if.org Git - php/commitdiff
Throw exception on invalid parameters in DateTime::__construct()
authorHannes Magnusson <bjori@php.net>
Mon, 6 Nov 2006 16:10:33 +0000 (16:10 +0000)
committerHannes Magnusson <bjori@php.net>
Mon, 6 Nov 2006 16:10:33 +0000 (16:10 +0000)
#makes sure the object doesnt get initialized with bogus parameters

ext/date/php_date.c

index 041bfd54e0f87d00b5437527d1810917b3c2e825..a892612407e6e74e08ecacf3d716ece61de939ea 100644 (file)
@@ -1807,11 +1807,11 @@ PHP_METHOD(DateTime, __construct)
        char *time_str = NULL;
        int time_str_len = 0;
        
+       php_set_error_handling(EH_THROW, NULL TSRMLS_CC);
        if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
-               php_set_error_handling(EH_THROW, NULL TSRMLS_CC);
                date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len, timezone_object TSRMLS_CC);
-               php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
        }
+       php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 }
 /* }}} */