Skip to content

Commit 94939d1

Browse files
committed
feedback
1 parent 524c5f3 commit 94939d1

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

ext/intl/collator/collator_convert.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ U_CFUNC zval* collator_convert_zstr_utf16_to_utf8( zval* utf16_zval, zval *rv )
181181
(UChar*) Z_STRVAL_P(utf16_zval), UCHARS( Z_STRLEN_P(utf16_zval) ), &status );
182182
if( !u8str ) {
183183
collator_set_conversion_error(status, "Error converting string from UTF-16 to UTF-8");
184+
ZVAL_NULL( rv );
184185
return nullptr;
185186
}
186187

ext/intl/collator/collator_sort.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ static int collator_numeric_compare_function(zval *result, zval *op1, zval *op2)
212212
*/
213213
static int collator_icu_compare_function(zval *result, zval *op1, zval *op2)
214214
{
215-
int rc = SUCCESS;
216215
zend_string *str1 = collator_zval_to_string(op1);
217216
if( str1 == nullptr ) {
218217
return FAILURE;
@@ -234,7 +233,7 @@ static int collator_icu_compare_function(zval *result, zval *op1, zval *op2)
234233
zend_string_release(str1);
235234
zend_string_release(str2);
236235

237-
return rc;
236+
return SUCCESS;
238237
}
239238
/* }}} */
240239

ext/intl/tests/collator_sort_conversion_error_regular.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ var_dump($array[0] instanceof BadRegularString);
1818
var_dump($array[1]);
1919
var_dump($coll->getErrorCode() === U_INVALID_CHAR_FOUND);
2020
echo $coll->getErrorMessage(), "\n";
21+
var_dump(intl_get_error_code() === U_INVALID_CHAR_FOUND);
22+
echo intl_get_error_message(), "\n";
2123

2224
$array = ['a', new BadRegularString()];
2325
var_dump($coll->sort($array, Collator::SORT_REGULAR));
2426
var_dump($coll->getErrorCode() === U_INVALID_CHAR_FOUND);
27+
var_dump(intl_get_error_code() === U_INVALID_CHAR_FOUND);
28+
echo intl_get_error_message(), "\n";
2529
var_dump($array[0], $array[1] instanceof BadRegularString);
2630

2731
$array = ['10', '9'];
@@ -40,8 +44,12 @@ bool(true)
4044
int(1)
4145
bool(true)
4246
Collator::sort(): Error converting object string from UTF-8 to UTF-16: U_INVALID_CHAR_FOUND
47+
bool(true)
48+
Collator::sort(): Error converting object string from UTF-8 to UTF-16: U_INVALID_CHAR_FOUND
4349
bool(false)
4450
bool(true)
51+
bool(true)
52+
Collator::sort(): Error converting object string from UTF-8 to UTF-16: U_INVALID_CHAR_FOUND
4553
string(1) "a"
4654
bool(true)
4755
bool(true)

0 commit comments

Comments
 (0)