summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Anderiasch <fa@php.net>2011-11-03 16:20:11 +0000
committerFlorian Anderiasch <fa@php.net>2011-11-03 16:20:11 +0000
commit8343d05e85996ce08889d35bf1a1c433fa587a6c (patch)
tree0445ca02ad6a18fb8fc42688e08db9a573c1029d
parent10a1121a37f0322e9ad954460635ab80eeb73c12 (diff)
downloadphp-git-8343d05e85996ce08889d35bf1a1c433fa587a6c.tar.gz
Redid the fix for #60192 with suggestions by Pierre and Kalle
-rwxr-xr-xext/intl/collator/collator_compare.c12
-rwxr-xr-xext/intl/collator/collator_locale.c7
-rwxr-xr-xext/intl/collator/collator_sort.c33
-rw-r--r--ext/intl/tests/bug60192-compare.phpt5
-rw-r--r--ext/intl/tests/bug60192-getlocale.phpt2
-rw-r--r--ext/intl/tests/bug60192-getsortkey.phpt2
-rw-r--r--ext/intl/tests/bug60192-sort.phpt2
-rw-r--r--ext/intl/tests/bug60192-sortwithsortkeys.phpt2
8 files changed, 42 insertions, 23 deletions
diff --git a/ext/intl/collator/collator_compare.c b/ext/intl/collator/collator_compare.c
index f7d01949cc..4384558ac6 100755
--- a/ext/intl/collator/collator_compare.c
+++ b/ext/intl/collator/collator_compare.c
@@ -58,6 +58,14 @@ PHP_FUNCTION( collator_compare )
/* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
+ if (!co || !co->ucoll) {
+ intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+ intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+ "Object not initialized", 0 TSRMLS_CC );
+ php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");
+
+ RETURN_FALSE;
+ }
/*
* Compare given strings (converting them to UTF-16 first).
@@ -99,10 +107,6 @@ PHP_FUNCTION( collator_compare )
RETURN_FALSE;
}
- if (!co || !co->ucoll) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
- }
-
/* Then compare them. */
result = ucol_strcoll(
co->ucoll,
diff --git a/ext/intl/collator/collator_locale.c b/ext/intl/collator/collator_locale.c
index eaa7e6ba35..b30b021ee8 100755
--- a/ext/intl/collator/collator_locale.c
+++ b/ext/intl/collator/collator_locale.c
@@ -52,7 +52,12 @@ PHP_FUNCTION( collator_get_locale )
COLLATOR_METHOD_FETCH_OBJECT;
if (!co || !co->ucoll) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
+ intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+ intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+ "Object not initialized", 0 TSRMLS_CC );
+ php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");
+
+ RETURN_FALSE;
}
/* Get locale by specified type. */
diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c
index a8fbd18e5e..a871c90a8e 100755
--- a/ext/intl/collator/collator_sort.c
+++ b/ext/intl/collator/collator_sort.c
@@ -73,9 +73,12 @@ static int collator_regular_compare_function(zval *result, zval *op1, zval *op2
/* Fetch collator object. */
co = (Collator_object *) zend_object_store_get_object( INTL_G(current_collator) TSRMLS_CC );
- if (!co || !co->ucoll) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
- }
+ if (!co || !co->ucoll) {
+ intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+ intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+ "Object not initialized", 0 TSRMLS_CC );
+ php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");
+ }
/* Compare the strings using ICU. */
result->value.lval = ucol_strcoll(
@@ -391,6 +394,14 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
/* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
+ if (!co || !co->ucoll) {
+ intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+ intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+ "Object not initialized", 0 TSRMLS_CC );
+ php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");
+
+ RETURN_FALSE;
+ }
/*
* Sort specified array.
@@ -445,10 +456,6 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
/* Get sort key, reallocating the buffer if needed. */
bufLeft = sortKeyBufSize - sortKeyBufOffset;
- if (!co || !co->ucoll) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
- }
-
sortKeyLen = ucol_getSortKey( co->ucoll,
utf16_buf,
utf16_len,
@@ -559,6 +566,14 @@ PHP_FUNCTION( collator_get_sort_key )
/* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
+ if (!co || !co->ucoll) {
+ intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
+ intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
+ "Object not initialized", 0 TSRMLS_CC );
+ php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Object not initialized");
+
+ RETURN_FALSE;
+ }
/*
* Compare given strings (converting them to UTF-16 first).
@@ -579,10 +594,6 @@ PHP_FUNCTION( collator_get_sort_key )
RETURN_FALSE;
}
- if (!co || !co->ucoll) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Object not initialized");
- }
-
key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, key, 0);
if(!key_len) {
efree( ustr );
diff --git a/ext/intl/tests/bug60192-compare.phpt b/ext/intl/tests/bug60192-compare.phpt
index d1db015d4a..0fd24cce80 100644
--- a/ext/intl/tests/bug60192-compare.phpt
+++ b/ext/intl/tests/bug60192-compare.phpt
@@ -6,7 +6,6 @@ Bug #60192 (SegFault when Collator not constructed properly)
?>
--FILE--
<?php
-
class Collator2 extends Collator{
public function __construct() {
// ommitting parent::__construct($someLocale);
@@ -14,7 +13,7 @@ class Collator2 extends Collator{
}
$c = new Collator2();
-$c->compare('h', 'H');
+$a = $c->compare('h', 'H');
--EXPECTF--
-Fatal error: Collator::compare(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::compare(): Object not initialized in %s on line %d
diff --git a/ext/intl/tests/bug60192-getlocale.phpt b/ext/intl/tests/bug60192-getlocale.phpt
index 0adb09223b..50e3ec35e4 100644
--- a/ext/intl/tests/bug60192-getlocale.phpt
+++ b/ext/intl/tests/bug60192-getlocale.phpt
@@ -17,4 +17,4 @@ $c = new Collator2();
$c->getLocale(Locale::ACTUAL_LOCALE);
--EXPECTF--
-Fatal error: Collator::getLocale(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::getLocale(): Object not initialized in %s on line %d
diff --git a/ext/intl/tests/bug60192-getsortkey.phpt b/ext/intl/tests/bug60192-getsortkey.phpt
index dedcfab8ba..39755ae8f9 100644
--- a/ext/intl/tests/bug60192-getsortkey.phpt
+++ b/ext/intl/tests/bug60192-getsortkey.phpt
@@ -17,4 +17,4 @@ $c = new Collator2();
$c->getSortKey('h');
--EXPECTF--
-Fatal error: Collator::getSortKey(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::getSortKey(): Object not initialized in %s on line %d
diff --git a/ext/intl/tests/bug60192-sort.phpt b/ext/intl/tests/bug60192-sort.phpt
index 35158995b6..57057215e6 100644
--- a/ext/intl/tests/bug60192-sort.phpt
+++ b/ext/intl/tests/bug60192-sort.phpt
@@ -18,4 +18,4 @@ $a = array('a', 'b');
$c->sort($a);
--EXPECTF--
-Fatal error: Collator::sort(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::sort(): Object not initialized in %s on line %d
diff --git a/ext/intl/tests/bug60192-sortwithsortkeys.phpt b/ext/intl/tests/bug60192-sortwithsortkeys.phpt
index a82fdda79a..445f4a03b9 100644
--- a/ext/intl/tests/bug60192-sortwithsortkeys.phpt
+++ b/ext/intl/tests/bug60192-sortwithsortkeys.phpt
@@ -18,4 +18,4 @@ $a = array('a', 'b');
$c->sortWithSortKeys($a);
--EXPECTF--
-Fatal error: Collator::sortWithSortKeys(): Object not initialized in %s on line %d
+Catchable fatal error: Collator::sortWithSortKeys(): Object not initialized in %s on line %d