From: Antony Dovgal Date: Tue, 5 Sep 2006 11:16:06 +0000 (+0000) Subject: fix leak in imap_utf8(), avoid extra strlen() call X-Git-Tag: RELEASE_1_0_0RC1~1774 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fcea7b3273226bb0f6c9dac83361bd6974799091;p=php fix leak in imap_utf8(), avoid extra strlen() call add test --- 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-- + +--FILE-- + +--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