]> granicus.if.org Git - php/commitdiff
initialize optional vars
authorArnaud Le Blanc <lbarnaud@php.net>
Tue, 21 Oct 2008 22:06:49 +0000 (22:06 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Tue, 21 Oct 2008 22:06:49 +0000 (22:06 +0000)
21 files changed:
ext/iconv/iconv.c
ext/mysql/php_mysql.c
ext/spl/spl_directory.c
ext/spl/spl_iterators.c
ext/standard/array.c
ext/standard/assert.c
ext/standard/basic_functions.c
ext/standard/browscap.c
ext/standard/crypt.c
ext/standard/file.c
ext/standard/filestat.c
ext/standard/head.c
ext/standard/html.c
ext/standard/info.c
ext/standard/mail.c
ext/standard/proc_open.c
ext/standard/rand.c
ext/standard/streamsfuncs.c
ext/standard/string.c
ext/standard/type.c
ext/standard/versioning.c

index 2c41037c3f520fbd6dc9f1ed952d2be233fc342a..6c4c4acbae75657f8026f551abc84bc49bfbd5d9 100644 (file)
@@ -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;
index 6a946a7a09a6aa69e482ac8a9dfb082e6ae4f64a..6890ad77fcbcc667f675d1b7a850d39a07c49a34 100644 (file)
@@ -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;
index ad02a7e628c22ab8c4ed79d0812dfc1119330806..4b012651c5191f5a880c309379a41ce23ff31b2b 100755 (executable)
@@ -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())
index 4f9953da287b2f0711640f0d61ce16e718419e6d..084ec37fcb57ffbc70c7f85697e74e2b93d6472a 100755 (executable)
@@ -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) {
index b5fefb72c21469d2999d002e5e0bbd6dd6ac973d..9bb96fc945c26e286daf171af146fb9456655c5f 100644 (file)
@@ -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;
 
index d29d8edff976084c26ba2703ac7f7f8ad259d97d..4f68ed0371b4efb192d4103027978a43fb2b8074 100644 (file)
@@ -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();
index f0b799e254246879533a1a38b88fff86dd1d5959..2f9f26eda82f8131656645dc6d72ae640a0c9848 100644 (file)
@@ -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) {
index f5ea50837f707183c5593bca325dae977abae8a4..5b583130acd5d1b27e39dc98c20df4876e7017ad 100644 (file)
@@ -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;
index cc7eaf435a69790712e37fef9c8c1d35c588c628..f8cd9d189c805fc6f9767c6f65ced18a06366b86 100644 (file)
@@ -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';
 
index 8f2669b957e41e2b1a07b41b7a869508f71dd6bf..0d91456fc2d142ccd5c371549e013ca2ee4aef7e 100644 (file)
@@ -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};
index 06b51c902c0567ac0d3f9841c39659886f5a243f..d500a96ca07c7f60517ebda094d61df86cd58db0 100644 (file)
@@ -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;
index d5903d446087f0b87522b6de79392751c27d8ae3..eca60369ed6b4d5e903ad75a48330c15700c99b7 100644 (file)
@@ -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;
 
index 2b0920722c39646890535ecb57042f3e59034cb5..194c532a97a7e6ea0e30d7ee931311e4283cc746 100644 (file)
@@ -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;
index 24ea0fe6ab7961f58b1736a0b5b051baf46953b7..0e4b5da94168312962eeeadf46cfe156efc5d595 100644 (file)
@@ -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) {
index 02b3b02ca7493b5334bcd12dd07ac73528e76711..39ce96f438d0a8e7d150d89cd3c3c7fc54bd00f7 100644 (file)
@@ -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;
index aa97fe0a99a5da450225bb50d7bb2022bf08d898..7e399c98e5affa647235d48651c1d1f3323a6007 100644 (file)
@@ -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;
index ab648a7345347d4b9eb7ed16be444c3d4a7b45d6..f66db96d16f71779c5ca64965998c92a0dc20039 100644 (file)
@@ -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;
index 5fcae2c19d54f091a6386957df45c160f417affc..a10e672a2c72b3e9cb4e4111e339ff90ca11066a 100644 (file)
@@ -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;
index ded24e001beac62cf35811d7e8ae2ce1effc4eb6..30eb52e6018c445c93a30d944e0c8fc122e78c1e 100644 (file)
@@ -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;
 
index 2055b2f0a3a29d871eafb5312b9062172268c27a..c575db9e834e7b78d9f49cdc5dd3caa2d1312db3 100644 (file)
@@ -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;
index 1ccc20a7877b5c3847a6ae712ef921f0725a8e77..0ee4d1e873d82d63f1e4c7783189c1bc1ed04b6e 100644 (file)
@@ -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();