summaryrefslogtreecommitdiff
path: root/ext/iconv
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2010-07-01 01:11:08 +0000
committerFelipe Pena <felipe@php.net>2010-07-01 01:11:08 +0000
commite3fdf31b0bf3b7b799ea25ba5ec14be194813e0b (patch)
treec03eb48c4f53746e947f17b723611b88153e1fd6 /ext/iconv
parent425c52878307e0b8cb3f9bdcea433b1e6e850802 (diff)
downloadphp-git-e3fdf31b0bf3b7b799ea25ba5ec14be194813e0b.tar.gz
- Fixed bug #52211 (iconv() returns part of string on error)
Diffstat (limited to 'ext/iconv')
-rw-r--r--ext/iconv/iconv.c5
-rw-r--r--ext/iconv/tests/bug52211.phpt13
2 files changed, 17 insertions, 1 deletions
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 07fb359a2b..40a03529bf 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -2357,9 +2357,12 @@ PHP_NAMED_FUNCTION(php_if_iconv)
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;
}
}
diff --git a/ext/iconv/tests/bug52211.phpt b/ext/iconv/tests/bug52211.phpt
new file mode 100644
index 0000000000..152aab839b
--- /dev/null
+++ b/ext/iconv/tests/bug52211.phpt
@@ -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)