From: Arnaud Le Blanc Date: Tue, 21 Oct 2008 22:06:49 +0000 (+0000) Subject: initialize optional vars X-Git-Tag: BEFORE_HEAD_NS_CHANGE~183 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ef7ecafc1e912bda9010c727cfe5c712f9eefb8;p=php initialize optional vars --- diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 2c41037c3f..6c4c4acbae 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -1935,7 +1935,7 @@ static void _php_iconv_show_error(php_iconv_err_t err, const char *out_charset, Returns the character count of str */ PHP_FUNCTION(iconv_strlen) { - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; zstr str; int str_len, argc = ZEND_NUM_ARGS(); @@ -1945,8 +1945,6 @@ PHP_FUNCTION(iconv_strlen) unsigned int retval; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(argc TSRMLS_CC, "t|s", &str, &str_len, &str_type, &charset, &charset_len) == FAILURE) { RETURN_FALSE; @@ -1975,19 +1973,17 @@ PHP_FUNCTION(iconv_strlen) Returns specified part of a string */ PHP_FUNCTION(iconv_substr) { - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; zstr str; int str_len; zend_uchar str_type; - long offset, length; + long offset, length = 0; php_iconv_err_t err; smart_str retval = {0}; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "tl|ls", &str, &str_len, &str_type, &offset, &length, &charset, &charset_len) == FAILURE) { @@ -2051,7 +2047,7 @@ PHP_FUNCTION(iconv_substr) Finds position of first occurrence of needle within part of haystack beginning with offset */ PHP_FUNCTION(iconv_strpos) { - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; zstr haystk; int haystk_len; @@ -2059,15 +2055,12 @@ PHP_FUNCTION(iconv_strpos) zstr ndl; int ndl_len; zend_uchar ndl_type; - long offset; + long offset = 0; php_iconv_err_t err; unsigned int retval; - offset = 0; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "TT|ls", &haystk, &haystk_len, &haystk_type, &ndl, &ndl_len, &ndl_type, &offset, &charset, &charset_len) == FAILURE) { @@ -2118,7 +2111,7 @@ PHP_FUNCTION(iconv_strpos) Finds position of last occurrence of needle within part of haystack beginning with offset */ PHP_FUNCTION(iconv_strrpos) { - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; char *haystk; int haystk_len; @@ -2129,8 +2122,6 @@ PHP_FUNCTION(iconv_strrpos) unsigned int retval; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s", &haystk, &haystk_len, &ndl, &ndl_len, &charset, &charset_len) == FAILURE) { @@ -2284,7 +2275,7 @@ PHP_FUNCTION(iconv_mime_decode) { char *encoded_str; int encoded_str_len; - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; long mode = 0; @@ -2292,8 +2283,6 @@ PHP_FUNCTION(iconv_mime_decode) php_iconv_err_t err; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &encoded_str, &encoded_str_len, &mode, &charset, &charset_len) == FAILURE) { @@ -2327,14 +2316,12 @@ PHP_FUNCTION(iconv_mime_decode_headers) { const char *encoded_str; int encoded_str_len; - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; long mode = 0; php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &encoded_str, &encoded_str_len, &mode, &charset, &charset_len) == FAILURE) { @@ -2510,7 +2497,7 @@ PHP_FUNCTION(iconv_set_encoding) PHP_FUNCTION(iconv_get_encoding) { char *type = "all"; - int type_len; + int type_len = sizeof("all")-1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type, &type_len) == FAILURE) return; diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 6a946a7a09..6890ad77fc 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -1160,7 +1160,7 @@ PHP_FUNCTION(mysql_get_server_info) Returns a string containing information about the most recent query */ PHP_FUNCTION(mysql_info) { - zval *mysql_link; + zval *mysql_link = NULL; int id = -1; char *str; php_mysql_conn *mysql; @@ -2040,8 +2040,8 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type, #endif if (into_object) { - char *class_name; - int class_name_len; + char *class_name = NULL; + int class_name_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|s&z", &res, &class_name, &class_name_len, UG(utf8_conv), &ctor_params) == FAILURE) { return; diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index ad02a7e628..4b012651c5 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -2340,8 +2340,8 @@ SPL_METHOD(SplFileObject, fgetcsv) { spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); char delimiter = intern->u.file.delimiter, enclosure = intern->u.file.enclosure, escape = intern->u.file.escape; - char *delim, *enclo, *esc; - int d_len, e_len, esc_len; + char *delim = NULL, *enclo = NULL, *esc = NULL; + int d_len = 0, e_len = 0, esc_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sss", &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) { switch(ZEND_NUM_ARGS()) @@ -2381,8 +2381,8 @@ SPL_METHOD(SplFileObject, setCsvControl) { spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); char delimiter = ',', enclosure = '"', escape='\\'; - char *delim, *enclo, *esc; - int d_len, e_len, esc_len; + char *delim = NULL, *enclo = NULL, *esc = NULL; + int d_len = 0, e_len = 0, esc_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sss", &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) { switch(ZEND_NUM_ARGS()) diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 4f9953da28..084ec37fcb 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1339,8 +1339,8 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z } case DIT_IteratorIterator: { zend_class_entry **pce_cast; - char * class_name; - int class_name_len; + char * class_name = NULL; + int class_name_len = 0; /* UTODO: class_name must be zstr */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|s", &zobject, ce_inner, &class_name, &class_name_len) == FAILURE) { diff --git a/ext/standard/array.c b/ext/standard/array.c index b5fefb72c2..9bb96fc945 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2165,14 +2165,14 @@ PHP_FUNCTION(array_unshift) PHP_FUNCTION(array_splice) { zval *array, /* Input array */ - *repl_array, /* Replacement array */ + *repl_array = NULL, /* Replacement array */ ***repl = NULL; /* Replacement elements */ HashTable *new_hash = NULL, /* Output array's hash */ **rem_hash = NULL; /* Removed elements' hash */ Bucket *p; /* Bucket used for traversing hash */ long i, offset, - length, + length = 0, repl_num = 0; /* Number of replacement elements */ int num_in; /* Number of elements in the input array */ @@ -2245,7 +2245,7 @@ PHP_FUNCTION(array_splice) PHP_FUNCTION(array_slice) { zval *input, /* Input array */ - **z_length, /* How many elements to get */ + **z_length = NULL, /* How many elements to get */ **entry; /* An array entry */ long offset, /* Offset to get elements from */ length = 0; @@ -4233,7 +4233,7 @@ PHP_FUNCTION(array_reduce) zval *retval; zend_fcall_info fci; zend_fcall_info_cache fci_cache = empty_fcall_info_cache; - zval *initial; + zval *initial = NULL; HashPosition pos; HashTable *htbl; diff --git a/ext/standard/assert.c b/ext/standard/assert.c index d29d8edff9..4f68ed0371 100644 --- a/ext/standard/assert.c +++ b/ext/standard/assert.c @@ -262,7 +262,7 @@ PHP_FUNCTION(assert) Set/get the various assert flags */ PHP_FUNCTION(assert_options) { - zval **value; + zval **value = NULL; long what; int oldint; int ac = ZEND_NUM_ARGS(); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index f0b799e254..2f9f26eda8 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -5010,9 +5010,9 @@ error options: PHP_FUNCTION(error_log) { char *message, *opt = NULL, *headers = NULL; - int message_len, opt_len, headers_len; + int message_len, opt_len = 0, headers_len = 0; int opt_err = 0, argc = ZEND_NUM_ARGS(); - long erropt; + long erropt = 0; if (zend_parse_parameters(argc TSRMLS_CC, "s|lss", &message, &message_len, &erropt, &opt, &opt_len, &headers, &headers_len) == FAILURE) { return; @@ -6031,7 +6031,7 @@ PHP_FUNCTION(connection_status) PHP_FUNCTION(ignore_user_abort) { char *arg = NULL; - int arg_len; + int arg_len = 0; int old_setting; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s&", &arg, &arg_len, UG(ascii_conv)) == FAILURE) { diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index f5ea50837f..5b583130ac 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -326,7 +326,7 @@ static int browser_reg_compare(zval **browser TSRMLS_DC, int num_args, va_list a PHP_FUNCTION(get_browser) { char *agent_name = NULL; - int agent_name_len; + int agent_name_len = 0; zend_bool return_array = 0; zval **agent, **z_agent_name; zval *found_browser_entry, *tmp_copy; diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c index cc7eaf435a..f8cd9d189c 100644 --- a/ext/standard/crypt.c +++ b/ext/standard/crypt.c @@ -137,7 +137,7 @@ PHP_FUNCTION(crypt) { char salt[PHP_MAX_SALT_LEN + 1]; char *str, *salt_in = NULL; - int str_len, salt_in_len; + int str_len, salt_in_len = 0; salt[0] = salt[PHP_MAX_SALT_LEN] = '\0'; diff --git a/ext/standard/file.c b/ext/standard/file.c index 8f2669b957..0d91456fc2 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1601,7 +1601,7 @@ PHP_FUNCTION(readfile) Return or change the umask */ PHP_FUNCTION(umask) { - long arg1; + long arg1 = 0; int oldumask; int arg_count = ZEND_NUM_ARGS(); @@ -2017,7 +2017,7 @@ PHP_FUNCTION(fputcsv) int ret; zval *fp = NULL, *fields = NULL, **field_tmp = NULL, field; char *delimiter_str = NULL, *enclosure_str = NULL; - int delimiter_str_len, enclosure_str_len; + int delimiter_str_len = 0, enclosure_str_len = 0; HashPosition pos; int count, i = 0; smart_str csvline = {0}; diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 06b51c902c..d500a96ca0 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -809,8 +809,8 @@ PHP_FUNCTION(clearstatcache) { zend_bool clear_realpath_cache = 0; char *filename = NULL; - zend_uchar filename_type; - int filename_len; + zend_uchar filename_type = 0; + int filename_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bt", &clear_realpath_cache, &filename, &filename_len, &filename_type) == FAILURE) { return; diff --git a/ext/standard/head.c b/ext/standard/head.c index d5903d4460..eca60369ed 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -201,7 +201,7 @@ PHP_FUNCTION(setrawcookie) Returns true if headers have already been sent, false otherwise */ PHP_FUNCTION(headers_sent) { - zval *arg1, *arg2; + zval *arg1 = NULL, *arg2 = NULL; char *file=""; int line=0; diff --git a/ext/standard/html.c b/ext/standard/html.c index 2b0920722c..194c532a97 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -1418,7 +1418,7 @@ PHP_FUNCTION(html_entity_decode) { zstr str; char *hint_charset = NULL; - int str_len, hint_charset_len, len; + int str_len, hint_charset_len = 0, len; char *str_utf8; int str_utf8_len; zend_uchar type; diff --git a/ext/standard/info.c b/ext/standard/info.c index 24ea0fe6ab..0e4b5da941 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -962,17 +962,12 @@ void register_phpinfo_constants(INIT_FUNC_ARGS) Output a page of useful information about PHP and the current request */ PHP_FUNCTION(phpinfo) { - int argc = ZEND_NUM_ARGS(); - long flag; + long flag = PHP_INFO_ALL; - if (zend_parse_parameters(argc TSRMLS_CC, "|l", &flag) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) { return; } - if(!argc) { - flag = PHP_INFO_ALL; - } - /* Andale! Andale! Yee-Hah! */ php_output_start_default(TSRMLS_C); php_print_info(flag TSRMLS_CC); @@ -1011,17 +1006,12 @@ PHP_FUNCTION(phpversion) Prints the list of people who've contributed to the PHP project */ PHP_FUNCTION(phpcredits) { - int argc = ZEND_NUM_ARGS(); - long flag; + long flag = PHP_CREDITS_ALL; - if (zend_parse_parameters(argc TSRMLS_CC, "|l", &flag) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) { return; } - if(!argc) { - flag = PHP_CREDITS_ALL; - } - php_print_credits(flag TSRMLS_CC); RETURN_TRUE; } @@ -1120,7 +1110,7 @@ PHP_FUNCTION(php_sapi_name) PHP_FUNCTION(php_uname) { char *mode = "a"; - int modelen; + int modelen = sizeof("a")-1; char *tmp; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &mode, &modelen) == FAILURE) { diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 02b3b02ca7..39ce96f438 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -94,8 +94,8 @@ PHP_FUNCTION(mail) { char *to=NULL, *message=NULL, *headers=NULL; char *subject=NULL, *extra_cmd=NULL; - int to_len, message_len, headers_len; - int subject_len, extra_cmd_len, i; + int to_len, message_len, headers_len = 0; + int subject_len, extra_cmd_len = 0, i; char *force_extra_parameters = INI_STR("mail.force_extra_parameters"); char *to_r, *subject_r; char *p, *e; diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index aa97fe0a99..7e399c98e5 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -432,7 +432,7 @@ PHP_FUNCTION(proc_open) { zval **ppcommand, **ppcwd = NULL; char *command, *cwd=NULL; - int command_len, cwd_len; + int command_len, cwd_len = 0; zval *descriptorspec; zval *pipes; zval *environment = NULL; diff --git a/ext/standard/rand.c b/ext/standard/rand.c index ab648a7345..f66db96d16 100644 --- a/ext/standard/rand.c +++ b/ext/standard/rand.c @@ -230,7 +230,7 @@ PHPAPI php_uint32 php_mt_rand(TSRMLS_D) Seeds random number generator */ PHP_FUNCTION(srand) { - long seed; + long seed = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &seed) == FAILURE) return; @@ -246,7 +246,7 @@ PHP_FUNCTION(srand) Seeds Mersenne Twister random number generator */ PHP_FUNCTION(mt_srand) { - long seed; + long seed = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &seed) == FAILURE) return; diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 5fcae2c19d..a10e672a2c 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -1427,7 +1427,7 @@ PHP_FUNCTION(stream_set_blocking) PHP_FUNCTION(stream_set_timeout) { zval *socket; - long seconds, microseconds; + long seconds, microseconds = 0; struct timeval t; php_stream *stream; int argc = ZEND_NUM_ARGS(); @@ -1489,7 +1489,7 @@ PHP_FUNCTION(stream_set_write_buffer) Enable or disable a specific kind of crypto on the stream */ PHP_FUNCTION(stream_socket_enable_crypto) { - long cryptokind; + long cryptokind = 0; zval *zstream, *zsessstream = NULL; php_stream *stream, *sessstream = NULL; zend_bool enable; diff --git a/ext/standard/string.c b/ext/standard/string.c index ded24e001b..30eb52e601 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -214,10 +214,8 @@ static void php_spn_common_handler(INTERNAL_FUNCTION_PARAMETERS, int behavior) / void *s1, *s2; int len1, len2; zend_uchar type1, type2; - long start, len; /* For UNICODE, these are codepoint units */ + long start = 0, len = 0; /* For UNICODE, these are codepoint units */ - start = 0; - len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "TT|ll", &s1, &len1, &type1, &s2, &len2, &type2, &start, &len) == FAILURE) { @@ -4297,8 +4295,8 @@ static void php_strtr_array(zval *return_value, char *str, int slen, HashTable * Translates characters in str using given translation tables */ PHP_FUNCTION(strtr) { - zstr str, to; - int str_len, to_len; + zstr str, to = NULL_ZSTR; + int str_len, to_len = 0; zend_uchar str_type, to_type; zval **from; int ac = ZEND_NUM_ARGS(); @@ -5683,7 +5681,7 @@ static void php_str_replace_in_subject(zval *search, zval *replace, zval **subje */ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensitivity) { - zval *subject, *search, *replace, **subject_entry, *zcount; + zval *subject, *search, *replace, **subject_entry, *zcount = NULL; zval *result; zstr string_key; uint string_key_len; @@ -7736,7 +7734,7 @@ static int php_str_word_count(char *str, int str_len, long type, char *char_list PHP_FUNCTION(str_word_count) { zstr str, char_list = NULL_ZSTR; - int str_len, char_list_len, word_count = 0; + int str_len, char_list_len = 0, word_count = 0; zend_uchar str_type; long type = 0; diff --git a/ext/standard/type.c b/ext/standard/type.c index 2055b2f0a3..c575db9e83 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -443,7 +443,7 @@ PHP_FUNCTION(is_scalar) Returns true if var is callable. */ PHP_FUNCTION(is_callable) { - zval *var, **callable_name; + zval *var, **callable_name = NULL; zval name; zend_bool retval; zend_bool syntax_only = 0; diff --git a/ext/standard/versioning.c b/ext/standard/versioning.c index 1ccc20a787..0ee4d1e873 100644 --- a/ext/standard/versioning.c +++ b/ext/standard/versioning.c @@ -213,8 +213,8 @@ php_version_compare(const char *orig_ver1, const char *orig_ver2) PHP_FUNCTION(version_compare) { - char *v1, *v2, *op; - int v1_len, v2_len, op_len; + char *v1, *v2, *op = NULL; + int v1_len, v2_len, op_len = 0; int compare, argc; argc = ZEND_NUM_ARGS();