From: Antony Dovgal Date: Tue, 5 Sep 2006 11:24:49 +0000 (+0000) Subject: fix leak in imap_utf8(), avoid extra strlen() call X-Git-Tag: php-5.2.0RC4~104 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c53ff1e801a8127b24a4bd551613a3f4bd4bc8d;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 dcaa200ead..a4e7b7ae0f 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -2178,7 +2178,10 @@ 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); + RETVAL_STRINGL(dest.data, dest.size, 1); + if (dest.data) { + free(dest.data); + } } /* }}} */ diff --git a/ext/imap/tests/imap_utf8.phpt b/ext/imap/tests/imap_utf8.phpt new file mode 100644 index 0000000000..dd432862f7 --- /dev/null +++ b/ext/imap/tests/imap_utf8.phpt @@ -0,0 +1,22 @@ +--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