From: Gustavo André dos Santos Lopes Date: Wed, 23 May 2012 11:22:06 +0000 (+0200) Subject: Fixed bug #62070 X-Git-Tag: php-5.4.4RC2~36^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51286bd8e5a7acd75326fae497313725e4acf234;p=php Fixed bug #62070 Collator::getSortKey() was returning an unterminated string due the length given to RETURN_STRINGL being off by one. --- diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c index a871c90a8e..0785111c96 100755 --- a/ext/intl/collator/collator_sort.c +++ b/ext/intl/collator/collator_sort.c @@ -594,6 +594,8 @@ PHP_FUNCTION( collator_get_sort_key ) RETURN_FALSE; } + /* ucol_getSortKey is exception in that the key length includes the + * NUL terminator*/ key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, key, 0); if(!key_len) { efree( ustr ); @@ -605,7 +607,7 @@ PHP_FUNCTION( collator_get_sort_key ) if(!key_len) { RETURN_FALSE; } - RETURN_STRINGL((char *)key, key_len, 0); + RETURN_STRINGL((char *)key, key_len - 1, 0); } /* }}} */ diff --git a/ext/intl/tests/bug62070.phpt b/ext/intl/tests/bug62070.phpt new file mode 100644 index 0000000000..a466b05c24 --- /dev/null +++ b/ext/intl/tests/bug62070.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #62070: Collator::getSortKey() returns garbage +--SKIPIF-- +