]> granicus.if.org Git - php/commitdiff
Fixed defective cloning in ext/intl classes
authorGustavo Lopes <glopes@nebm.ist.utl.pt>
Sun, 26 Aug 2012 21:37:09 +0000 (23:37 +0200)
committerGustavo Lopes <glopes@nebm.ist.utl.pt>
Sun, 26 Aug 2012 21:53:57 +0000 (23:53 +0200)
See also bug #62915

Cherry picked from 886a50a (I forgot about 5.3)

Conflicts:
ext/intl/spoofchecker/spoofchecker_class.c
ext/intl/transliterator/transliterator_class.c

NEWS
ext/intl/dateformat/dateformat_class.c
ext/intl/formatter/formatter_class.c
ext/intl/msgformat/msgformat_class.c
ext/intl/tests/bug62915-2.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 69cbb2a0fa58a1c7c0e3614211b0084375ebe9f9..cd7333cbb220bf2403996d72e05d1ba018dcfbde 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ PHP                                                                        NEWS
 
 - Intl:
   . Fix null pointer dereferences in some classes of ext/intl. (Gustavo)
+  . Fix bug #62915 (defective cloning in several intl classes). (Gustavo)
 
 - MySQLnd:
   . Fixed bug #62885 (mysqli_poll - Segmentation fault). (Laruence)
index 85a67f7f9fc6ea3d00e90d3e7e7b8089c49acd63..a7227ef03d76637dd1f50eaf716961ed37c7a71a 100644 (file)
@@ -91,7 +91,7 @@ zend_object_value IntlDateFormatter_object_clone(zval *object TSRMLS_DC)
 
        DATE_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK;
 
-       new_obj_val = IntlDateFormatter_ce_ptr->create_object(IntlDateFormatter_ce_ptr TSRMLS_CC);
+       new_obj_val = IntlDateFormatter_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC);
        new_dfo = (IntlDateFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC);
        /* clone standard parts */      
        zend_objects_clone_members(&new_dfo->zo, new_obj_val, &dfo->zo, handle TSRMLS_CC);
index 5790f0c2e198ff93b323560155e227ec7a7c11b6..9de1e1e96e6e18e48a56e49ec848a0a86ef8e06e 100644 (file)
@@ -85,7 +85,7 @@ zend_object_value NumberFormatter_object_clone(zval *object TSRMLS_DC)
        NumberFormatter_object *nfo, *new_nfo;
 
        FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK;
-       new_obj_val = NumberFormatter_ce_ptr->create_object(NumberFormatter_ce_ptr TSRMLS_CC);
+       new_obj_val = NumberFormatter_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC);
        new_nfo = (NumberFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC);
        /* clone standard parts */      
        zend_objects_clone_members(&new_nfo->zo, new_obj_val, &nfo->zo, handle TSRMLS_CC);
index 36d06d2d3652f2ccbc19cd286240499fb56221cd..d6ba9b1c670945845b1eae4df24d304eedcd948b 100644 (file)
@@ -83,7 +83,7 @@ zend_object_value MessageFormatter_object_clone(zval *object TSRMLS_DC)
        MessageFormatter_object *mfo, *new_mfo;
 
        MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK;
-       new_obj_val = MessageFormatter_ce_ptr->create_object(MessageFormatter_ce_ptr TSRMLS_CC);
+       new_obj_val = MessageFormatter_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC);
        new_mfo = (MessageFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC);
        /* clone standard parts */      
        zend_objects_clone_members(&new_mfo->zo, new_obj_val, &mfo->zo, handle TSRMLS_CC);
diff --git a/ext/intl/tests/bug62915-2.phpt b/ext/intl/tests/bug62915-2.phpt
new file mode 100644 (file)
index 0000000..6bccf38
--- /dev/null
@@ -0,0 +1,29 @@
+--TEST--
+Bug #62915: cloning of several classes is defective
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+           die('skip intl extension not enabled');
+--FILE--
+<?php
+class A extends IntlDateFormatter {
+               static $ARGS = array("en_US" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL,
+                   'America/Los_Angeles', IntlDateFormatter::GREGORIAN);
+}
+class B extends NumberFormatter {
+               static $ARGS = array('de_DE', NumberFormatter::DECIMAL);
+}
+class C extends MessageFormatter {
+               static $ARGS = array("en_US", "foo");
+}
+
+foreach (range('A', 'C') as $subclass) {
+               $rc = new ReflectionClass($subclass);
+                       $obj = $rc->newInstanceArgs($subclass::$ARGS);
+                               $clone = clone $obj;
+                                       var_dump(get_class($clone));
+}
+--EXPECT--
+string(1) "A"
+string(1) "B"
+string(1) "C"