felipe                                   Thu, 01 Jul 2010 01:11:08 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=300894

Log:
- Fixed bug #52211 (iconv() returns part of string on error)

Bug: http://bugs.php.net/52211 (Open) iconv() returns part of string on error
      
Changed paths:
    U   php/php-src/trunk/NEWS
    U   php/php-src/trunk/ext/iconv/iconv.c
    A   php/php-src/trunk/ext/iconv/tests/bug52211.phpt

Modified: php/php-src/trunk/NEWS
===================================================================
--- php/php-src/trunk/NEWS      2010-07-01 00:14:04 UTC (rev 300893)
+++ php/php-src/trunk/NEWS      2010-07-01 01:11:08 UTC (rev 300894)
@@ -85,6 +85,8 @@

 - Fixed PDO objects binary incompatibility. (Dmitry)

+- Fixed bug #52211 (iconv() returns part of string on error). (Felipe)
+

 ?? ??? 20??, PHP 5.3.3
 - Upgraded bundled PCRE to version 8.01. (Ilia)

Modified: php/php-src/trunk/ext/iconv/iconv.c
===================================================================
--- php/php-src/trunk/ext/iconv/iconv.c 2010-07-01 00:14:04 UTC (rev 300893)
+++ php/php-src/trunk/ext/iconv/iconv.c 2010-07-01 01:11:08 UTC (rev 300894)
@@ -2357,9 +2357,12 @@
        err = php_iconv_string(in_buffer, (size_t)in_buffer_len,
                &out_buffer, &out_len, out_charset, in_charset);
        _php_iconv_show_error(err, out_charset, in_charset TSRMLS_CC);
-       if (out_buffer != NULL) {
+       if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) {
                RETVAL_STRINGL(out_buffer, out_len, 0);
        } else {
+               if (out_buffer != NULL) {
+                       efree(out_buffer);
+               }
                RETURN_FALSE;
        }
 }

Added: php/php-src/trunk/ext/iconv/tests/bug52211.phpt
===================================================================
--- php/php-src/trunk/ext/iconv/tests/bug52211.phpt                             
(rev 0)
+++ php/php-src/trunk/ext/iconv/tests/bug52211.phpt     2010-07-01 01:11:08 UTC 
(rev 300894)
@@ -0,0 +1,13 @@
+--TEST--
+Bug #52211 (iconv() returns part of string on error)
+--FILE--
+<?php
+
+$str = "PATHOLOGIES MÉDICO-CHIRUR. ADUL. PL";
+$str_iconv = iconv('CP850', 'ISO-8859-1', $str );
+var_dump($str_iconv);
+
+?>
+--EXPECTF--
+Notice: iconv(): Detected an illegal character in input string in %s on line %d
+bool(false)


Property changes on: php/php-src/trunk/ext/iconv/tests/bug52211.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to