Skip to content

Commit b09497c

Browse files
remicolletweltling
authored andcommitted
Fixed bug #75193 segfault in collator_convert_object_to_string
1 parent 5cf2155 commit b09497c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

ext/intl/collator/collator_sort.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ static int collator_regular_compare_function(zval *result, zval *op1, zval *op2)
5959
zval norm1, norm2;
6060
zval *num1_p = NULL, *num2_p = NULL;
6161
zval *norm1_p = NULL, *norm2_p = NULL;
62-
zval* str1_p = collator_convert_object_to_string( op1, &str1 );
63-
zval* str2_p = collator_convert_object_to_string( op2, &str2 );
62+
zval *str1_p, *str2_p;
63+
64+
ZVAL_NULL(&str1);
65+
str1_p = collator_convert_object_to_string( op1, &str1 );
66+
ZVAL_NULL(&str2);
67+
str2_p = collator_convert_object_to_string( op2, &str2 );
6468

6569
/* If both args are strings AND either of args is not numeric string
6670
* then use ICU-compare. Otherwise PHP-compare. */

ext/intl/tests/bug75193.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #75193 segfault in collator_convert_object_to_string
3+
--SKIPIF--
4+
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5+
--FILE--
6+
<?php
7+
$a = new \Collator('en_US');
8+
$b = [new stdclass, new stdclass];
9+
var_dump($a->sort($b));
10+
?>
11+
===DONE===
12+
--EXPECT--
13+
bool(true)
14+
===DONE===

0 commit comments

Comments
 (0)