From: Moriyoshi Koizumi Date: Sun, 6 Jul 2003 21:30:23 +0000 (+0000) Subject: Fixed segfault due to reference to the already free'd block :) X-Git-Tag: BEFORE_ARG_INFO~358 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80a8ff3a43c13828f47fd66d144c77862c2f4937;p=php Fixed segfault due to reference to the already free'd block :) --- diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 9e1a2c544b..fd78adae4e 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -1600,7 +1600,7 @@ PHP_FUNCTION(iconv_mime_encode) char *in_charset; char *out_charset; long line_len = 76; - char *lfchars = "\r\n"; + zval lfchars; php_iconv_enc_scheme_t scheme_id = PHP_ICONV_ENC_SCHEME_BASE64; @@ -1664,23 +1664,18 @@ PHP_FUNCTION(iconv_mime_encode) } if (zend_hash_find(Z_ARRVAL_P(pref), "line-break-chars", sizeof("line-break-chars"), (void **)&ppval) == SUCCESS) { - pval = *ppval; - if (Z_TYPE_P(pval) != IS_STRING) { - val = *pval; - zval_copy_ctor(&val); - convert_to_string(&val); - pval = &val; - } + lfchars = **ppval; + zval_copy_ctor(&lfchars); - lfchars = Z_STRVAL_P(pval); - - if (pval == &val) { - zval_dtor(&val); + if (Z_TYPE(lfchars) != IS_STRING) { + convert_to_string(&lfchars); } + } else { + ZVAL_STRING(&lfchars, "\r\n", 1); } err = _php_iconv_mime_encode(&retval, field_name, field_name_len, - field_value, field_value_len, line_len, lfchars, scheme_id, + field_value, field_value_len, line_len, Z_STRVAL(lfchars), scheme_id, out_charset, in_charset); _php_iconv_show_error(err, out_charset, in_charset TSRMLS_CC); @@ -1694,6 +1689,8 @@ PHP_FUNCTION(iconv_mime_encode) smart_str_free(&retval); RETVAL_FALSE; } + + zval_dtor(&lfchars); } /* }}} */