]> granicus.if.org Git - php/commitdiff
Fixed segfault in intlgregcal_create_instance
authorXinchen Hui <laruence@php.net>
Sun, 29 Jun 2014 14:56:27 +0000 (22:56 +0800)
committerXinchen Hui <laruence@php.net>
Sun, 29 Jun 2014 14:56:27 +0000 (22:56 +0800)
ext/intl/calendar/gregoriancalendar_methods.cpp
ext/intl/intl_data.h

index e08d2637236f383ea4f4611d55c6a87b9753ae7c..41e2735485be64b226c54a614f7ee2837622d545 100644 (file)
@@ -182,7 +182,8 @@ U_CFUNC PHP_FUNCTION(intlgregcal_create_instance)
        _php_intlgregcal_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
 
        if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
-               zend_object_store_ctor_failed(Z_OBJ(orig) TSRMLS_CC);
+               zval_dtor(&orig);
+               RETURN_NULL();
        }
 }
 
index 4dd1508468ba1e7758f83bf35e451daab2a6cd93..1b764a2ab1b8139d761a59bad60853bc2e7678f8 100644 (file)
@@ -69,6 +69,11 @@ typedef struct _intl_data {
     if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) )                                                                     \
     {                                                                                                                                                          \
         intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 TSRMLS_CC );      \
+               /* yes, this is ugly, but it alreay is */                                                                       \
+               if (return_value != getThis()) {                                                                                        \
+                       zval_dtor(return_value);                                                                                                \
+                       RETURN_NULL();                                                                                                                  \
+               }                                                                                                                                                       \
                Z_OBJ_P(return_value) = NULL;                                                                                           \
                return;                                                                                                                                         \
     }