summaryrefslogtreecommitdiff
path: root/ext/iconv
diff options
context:
space:
mode:
Diffstat (limited to 'ext/iconv')
-rw-r--r--ext/iconv/iconv.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index dbe9afbd9a..b1c587fb21 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -1873,7 +1873,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;
char *str;
int str_len;
@@ -1882,8 +1882,6 @@ PHP_FUNCTION(iconv_strlen)
unsigned int retval;
- charset = ICONVG(internal_encoding);
-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
&str, &str_len, &charset, &charset_len) == FAILURE) {
RETURN_FALSE;
@@ -1908,18 +1906,16 @@ 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;
char *str;
int str_len;
- 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, "sl|ls",
&str, &str_len, &offset, &length,
&charset, &charset_len) == FAILURE) {
@@ -1950,21 +1946,18 @@ 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;
char *haystk;
int haystk_len;
char *ndl;
int ndl_len;
- 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, "ss|ls",
&haystk, &haystk_len, &ndl, &ndl_len,
&offset, &charset, &charset_len) == FAILURE) {
@@ -2001,7 +1994,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;
@@ -2012,8 +2005,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) {
@@ -2167,7 +2158,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;
@@ -2175,8 +2166,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) {
@@ -2210,14 +2199,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) {
@@ -2422,7 +2409,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;