summaryrefslogtreecommitdiff
path: root/ext/imap
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2006-09-05 11:16:06 +0000
committerAntony Dovgal <tony2001@php.net>2006-09-05 11:16:06 +0000
commitfcea7b3273226bb0f6c9dac83361bd6974799091 (patch)
tree2acdeff5dc4efb451020e0a06884dc9bcc3b7ab8 /ext/imap
parent13427fc603b4d6b83ba7002484aed77aaed4c7fa (diff)
downloadphp-git-fcea7b3273226bb0f6c9dac83361bd6974799091.tar.gz
fix leak in imap_utf8(), avoid extra strlen() call
add test
Diffstat (limited to 'ext/imap')
-rw-r--r--ext/imap/php_imap.c2
-rw-r--r--ext/imap/tests/imap_utf8.phpt30
2 files changed, 31 insertions, 1 deletions
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index f9a99be356..b6b9731c9e 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -2174,7 +2174,7 @@ PHP_FUNCTION(imap_utf8)
cpytxt(&src, Z_STRVAL_PP(str), Z_STRLEN_PP(str));
utf8_mime2text(&src, &dest);
- RETURN_STRINGL(dest.data, strlen(dest.data), 1);
+ RETURN_STRINGL(dest.data, dest.size, 0);
}
/* }}} */
diff --git a/ext/imap/tests/imap_utf8.phpt b/ext/imap/tests/imap_utf8.phpt
new file mode 100644
index 0000000000..81a25c85f7
--- /dev/null
+++ b/ext/imap/tests/imap_utf8.phpt
@@ -0,0 +1,30 @@
+--TEST--
+imap_utf8() tests
+--SKIPIF--
+<?php if (!extension_loaded("imap")) print "skip"; ?>
+--FILE--
+<?php
+
+var_dump(imap_utf8(""));
+var_dump(imap_utf8(1));
+var_dump(imap_utf8(array(1,2)));
+var_dump(imap_utf8("test"));
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(0) ""
+string(1) "1"
+
+Notice: Array to string conversion in %s on line %d
+string(5) "Array"
+string(4) "test"
+Done
+--UEXPECTF--
+string(0) ""
+string(1) "1"
+
+Notice: Array to string conversion in %s on line %d
+string(5) "Array"
+string(4) "test"
+Done