]> granicus.if.org Git - php/commitdiff
Fix memory leak
authorAnatol Belski <ab@php.net>
Thu, 12 Apr 2018 16:25:27 +0000 (18:25 +0200)
committerAnatol Belski <ab@php.net>
Thu, 12 Apr 2018 16:25:27 +0000 (18:25 +0200)
ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
ext/intl/tests/rbbiter___construct_basic.phpt

index 8ab8194b17ab7de6ea6d52ae1beec743ad286cff..fbc3fe6f5cdcdf3f0f2098f073cb2b4465626972 100644 (file)
@@ -79,6 +79,7 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
                if (U_FAILURE(status)) {
                        intl_error_set(NULL, status, "rbbi_create_instance: unable to "
                                "create instance from compiled rules", 0);
+                       delete rbbi;
                        return;
                }
 #else
index 6fb584fdee5b8a3831cd7c23d55101c1b2100edf..31edcd2c83d051f172d59c84e9e12ed8f75560a6 100644 (file)
@@ -24,8 +24,17 @@ $rules = <<<RULES
 RULES;
 $rbbi = new IntlRuleBasedBreakIterator($rules);
 var_dump(get_class($rbbi));
+
+try {
+       $obj = new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+', 'aoeu');
+} catch (IntlException $e) {
+       var_dump(intl_get_error_code(), intl_get_error_message());
+}
+
 ?>
 ==DONE==
 --EXPECT--
 string(26) "IntlRuleBasedBreakIterator"
-==DONE==
\ No newline at end of file
+int(1)
+string(93) "rbbi_create_instance: unable to create instance from compiled rules: U_ILLEGAL_ARGUMENT_ERROR"
+==DONE==