From: Arnaud Le Blanc Date: Tue, 21 Oct 2008 23:36:17 +0000 (+0000) Subject: initialize optional vars X-Git-Tag: BEFORE_HEAD_NS_CHANGE~182 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51f7cc3925bf67540042507d609a5678f3196312;p=php initialize optional vars --- diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 33a1d26365..f10376bcd7 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1092,8 +1092,8 @@ PHP_FUNCTION(curl_init) php_curl *ch; CURL *cp; zstr src = NULL_ZSTR; - int src_len; - zend_uchar src_type; + int src_len = 0; + zend_uchar src_type = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|t", &src, &src_len, &src_type) == FAILURE) { RETURN_FALSE; @@ -1783,7 +1783,7 @@ PHP_FUNCTION(curl_getinfo) { zval *zid; php_curl *ch; - long option; + long option = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &zid, &option) == FAILURE) { RETURN_FALSE; diff --git a/ext/date/php_date.c b/ext/date/php_date.c index c4848eecdb..61e9e808ec 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1511,7 +1511,7 @@ PHP_FUNCTION(idate) { char *format; int format_len; - long ts; + long ts = 0; int ret; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &format, &format_len, &ts) == FAILURE) { @@ -1574,7 +1574,7 @@ PHP_FUNCTION(strtotime) char *times, *initial_ts; int time_len, error1, error2; struct timelib_error_container *error; - long preset_ts, ts; + long preset_ts = 0, ts; timelib_time *t, *now; timelib_tzinfo *tzi; @@ -1631,7 +1631,7 @@ PHP_FUNCTION(strtotime) /* {{{ php_mktime - (gm)mktime helper */ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt) { - long hou, min, sec, mon, day, yea, dst = -1; + long hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0, dst = -1; timelib_time *now; timelib_tzinfo *tzi = NULL; long ts, adjust_seconds = 0; @@ -1760,7 +1760,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt) { char *format, *buf; int format_len; - long timestamp; + long timestamp = 0; struct tm ta; int max_reallocs = 5; size_t buf_len = 64, real_len; @@ -3962,7 +3962,7 @@ PHP_FUNCTION(timezone_identifiers_list) const timelib_tzdb_index_entry *table; int i, item_count; long what = PHP_DATE_TIMEZONE_GROUP_ALL; - char *option; + char *option = NULL; int option_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ls", &what, &option, &option_len) == FAILURE) { @@ -4068,10 +4068,10 @@ PHP_FUNCTION(date_default_timezone_get) */ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_sunset) { - double latitude, longitude, zenith, gmt_offset = 0, altitude; + double latitude = 0.0, longitude = 0.0, zenith = 0.0, gmt_offset = 0, altitude; double h_rise, h_set, N; timelib_sll rise, set, transit; - long time, retformat; + long time, retformat = 0; int rs; timelib_time *t; timelib_tzinfo *tzi; diff --git a/ext/dom/domimplementation.c b/ext/dom/domimplementation.c index a32f075c20..d1d7642041 100644 --- a/ext/dom/domimplementation.c +++ b/ext/dom/domimplementation.c @@ -98,7 +98,7 @@ PHP_METHOD(domimplementation, createDocumentType) zval *rv = NULL; xmlDtd *doctype; int ret, name_len = 0, publicid_len = 0, systemid_len = 0; - char *name, *publicid, *systemid; + char *name = NULL, *publicid = NULL, *systemid = NULL; xmlChar *pch1 = NULL, *pch2 = NULL, *localname = NULL; xmlURIPtr uri; @@ -161,7 +161,7 @@ PHP_METHOD(domimplementation, createDocument) xmlDtdPtr doctype = NULL; xmlNsPtr nsptr = NULL; int ret, uri_len = 0, name_len = 0, errorcode = 0; - char *uri, *name; + char *uri = NULL, *name = NULL; char *prefix = NULL, *localname = NULL; dom_object *doctobj; diff --git a/ext/exif/exif.c b/ext/exif/exif.c index 89beb724ec..580ad5563c 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -3892,7 +3892,7 @@ PHP_FUNCTION(exif_read_data) image_info_type ImageInfo; char tmp[64], *sections_str=0, *s; char *filename; - int filename_len, sections_str_len; + int filename_len, sections_str_len = 0; memset(&ImageInfo, 0, sizeof(ImageInfo)); diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 66fbdaac65..d1aeb009e5 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -4144,7 +4144,7 @@ PHP_FUNCTION(imagepstext) PHP_FUNCTION(imagepsbbox) { zval *fnt; - long sz = 0, sp, wd; + long sz = 0, sp = 0, wd = 0; char *str; int i, space = 0, add_width = 0, char_width, amount_kern; int cur_x, cur_y, dx, dy; @@ -4152,7 +4152,7 @@ PHP_FUNCTION(imagepsbbox) int *f_ind; int str_len, per_char = 0; int argc = ZEND_NUM_ARGS(); - double angle, sin_a = 0, cos_a = 0; + double angle = 0, sin_a = 0, cos_a = 0; BBox char_bbox, str_bbox = {0, 0, 0, 0}; if (argc != 3 && argc != 6) { diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 114c413a2c..e461390f70 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1550,7 +1550,7 @@ PHP_FUNCTION(openssl_x509_checkpurpose) long purpose; zval **ppuntrusted=NULL; char * untrusted = NULL; - int untrusted_len; + int untrusted_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl|a!Z", &zcert, &purpose, &zcainfo, &ppuntrusted) == FAILURE) { return; @@ -3279,7 +3279,7 @@ PHP_FUNCTION(openssl_pkey_get_private) zval **cert; EVP_PKEY *pkey; char *passphrase = ""; - int passphrase_len; + int passphrase_len = sizeof("")-1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|s&", &cert, &passphrase, &passphrase_len, UG(ascii_conv)) == FAILURE) { return; @@ -3413,11 +3413,11 @@ PHP_FUNCTION(openssl_pkcs7_verify) zval **ppfilename; char * filename; int filename_len; zval **ppextracerts=NULL; - char * extracerts = NULL; int extracerts_len; + char * extracerts = NULL; int extracerts_len = 0; zval **ppsignersfilename; - char * signersfilename = NULL; int signersfilename_len; + char * signersfilename = NULL; int signersfilename_len = 0; zval **ppdatafilename=NULL; - char * datafilename = NULL; int datafilename_len; + char * datafilename = NULL; int datafilename_len = 0; RETVAL_LONG(-1); @@ -4339,7 +4339,7 @@ PHP_FUNCTION(openssl_seal) unsigned char *buf = NULL, **eks; char *data; int data_len; char *method =NULL; - int method_len; + int method_len = 0; const EVP_CIPHER *cipher; EVP_CIPHER_CTX ctx; @@ -4465,7 +4465,7 @@ PHP_FUNCTION(openssl_open) char * data; int data_len; char * ekey; int ekey_len; char *method =NULL; - int method_len; + int method_len = 0; const EVP_CIPHER *cipher; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SzSZ|s&", &data, &data_len, &opendata, &ekey, &ekey_len, &privkey, &method, &method_len, UG(ascii_conv)) == FAILURE) { diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index cd610f4476..3f71bbdb82 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1546,7 +1546,7 @@ SXE_METHOD(children) { php_sxe_object *sxe; char *nsprefix = NULL; - int nsprefix_len; + int nsprefix_len = 0; xmlNodePtr node; zend_bool isprefix = 0; @@ -1595,7 +1595,7 @@ SXE_METHOD(attributes) { php_sxe_object *sxe; char *nsprefix = NULL; - int nsprefix_len; + int nsprefix_len = 0; xmlNodePtr node; zend_bool isprefix = 0; diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 3fe8f68495..40c40f305e 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1211,9 +1211,9 @@ PHP_METHOD(SoapFault, SoapFault) zstr fault_actor = NULL_ZSTR; zstr name = NULL_ZSTR; char *fault_code = NULL, *fault_code_ns = NULL; - int fault_string_len, fault_actor_len, name_len; + int fault_string_len = 0, fault_actor_len = 0, name_len = 0; zval *code = NULL, *details = NULL, *headerfault = NULL; - zend_uchar name_type, fault_string_type, fault_actor_type; + zend_uchar name_type = 0, fault_string_type = 0, fault_actor_type = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zt|t!z!t!z", &code, @@ -1342,8 +1342,8 @@ PHP_METHOD(SoapVar, SoapVar) { zval *data, *type; zstr stype = NULL_ZSTR, ns = NULL_ZSTR, name = NULL_ZSTR, namens = NULL_ZSTR; - int stype_len, ns_len, name_len, namens_len; - zend_uchar stype_type, ns_type, name_type, namens_type; + int stype_len = 0, ns_len = 0, name_len = 0, namens_len = 0; + zend_uchar stype_type = 0, ns_type = 0, name_type = 0, namens_type = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!z|tttt", &data, &type, @@ -1940,7 +1940,7 @@ PHP_METHOD(SoapServer, handle) soapHeader *soap_headers = NULL; sdlFunctionPtr function; zstr arg = NULL_ZSTR; - int arg_len; + int arg_len = 0; xmlCharEncodingHandlerPtr old_encoding; HashTable *old_class_map, *old_typemap; int old_features; @@ -2478,8 +2478,8 @@ PHP_METHOD(SoapServer, fault) zstr code, string; zstr actor=NULL_ZSTR; zstr name=NULL_ZSTR; - int code_len, string_len, actor_len, name_len; - zend_uchar code_type, string_type, actor_type, name_type; + int code_len, string_len, actor_len = 0, name_len = 0; + zend_uchar code_type, string_type, actor_type = 0, name_type = 0; zval* details = NULL; SOAP_SERVER_BEGIN_CODE(); @@ -3695,8 +3695,8 @@ PHP_METHOD(SoapClient, __setCookie) { zstr name; zstr val = NULL_ZSTR; - int name_len, val_len; - zend_uchar name_type, val_type; + int name_len, val_len = 0; + zend_uchar name_type, val_type = 0; soap_client_object *client; client = (soap_client_object*)zend_object_store_get_object(this_ptr TSRMLS_CC); @@ -3796,8 +3796,8 @@ PHP_METHOD(SoapClient, __setSoapHeaders) PHP_METHOD(SoapClient, __setLocation) { void* location = NULL; - int location_len; - zend_uchar location_type; + int location_len = 0; + zend_uchar location_type = 0; soap_client_object *client; client = (soap_client_object*)zend_object_store_get_object(this_ptr TSRMLS_CC); diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 5e2b09c548..e05a40e257 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -976,7 +976,7 @@ PHP_FUNCTION(socket_write) zval *arg1; php_socket *php_sock; int retval, str_len; - long length; + long length = 0; char *str; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, &str, &str_len, &length) == FAILURE) { @@ -1270,7 +1270,7 @@ PHP_FUNCTION(socket_connect) struct sockaddr_un s_un; char *addr; int retval, addr_len; - long port; + long port = 0; int argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc TSRMLS_CC, "rs|l", &arg1, &addr, &addr_len, &port) == FAILURE) { diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 220b6e8317..ab7a9642ac 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1143,8 +1143,8 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_open) { zval * zip; zval * zip_entry; - char *mode; - int mode_len; + char *mode = NULL; + int mode_len = 0; zip_read_rsrc * zr_rsrc; zip_rsrc *z_rsrc; @@ -1486,10 +1486,10 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* struct zip *intern; zval *this = getThis(); char *pattern; - char *path; + char *path = NULL; char *remove_path = NULL; char *add_path = NULL; - int pattern_len, add_path_len, remove_path_len, path_len; + int pattern_len, add_path_len, remove_path_len, path_len = 0; long remove_all_path = 0; long flags = 0; zval *options = NULL;