From 490e7fd6fd6ec7b6094d2441692c31af6c00ca50 Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Sat, 6 Sep 2003 06:57:40 +0000 Subject: [PATCH] Fix segfault on uninitialized zval, skip NULL/Resource types, fix integer value handling, and process doubles/bools more efficiently. --- ext/standard/http.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ext/standard/http.c b/ext/standard/http.c index b949fd3dc7c..892f02b99df 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -115,6 +115,9 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, php_url_encode_hash_ex(Z_ARRVAL_PP(zdata), formstr, NULL, 0, newprefix, newprefix_len, "]", 1 TSRMLS_CC); ht->nApplyCount--; efree(newprefix); + } else if (Z_TYPE_PP(zdata) == IS_NULL || Z_TYPE_PP(zdata) == IS_RESOURCE) { + /* Skip these types */ + continue; } else { if (formstr->len) { smart_str_appendl(formstr, arg_sep, arg_sep_len); @@ -141,10 +144,15 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, ekey = php_url_encode(Z_STRVAL_PP(zdata), Z_STRLEN_PP(zdata), &ekey_len); break; case IS_LONG: - ekey_len = spprintf(&ekey, 12, "%ld", idx); + case IS_BOOL: + ekey_len = spprintf(&ekey, 12, "%ld", Z_LVAL_PP(zdata)); + break; + case IS_DOUBLE: + ekey_len = spprintf(&ekey, 48, "%.*G", (int) EG(precision), Z_DVAL_PP(zdata)); break; default: /* fall back on convert to string */ + MAKE_STD_ZVAL(copyzval); *copyzval = **zdata; zval_copy_ctor(copyzval); convert_to_string_ex(©zval);