Skip to content

Commit 14aee57

Browse files
committed
Add free if U_FAILED
1 parent 3baf919 commit 14aee57

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ext/intl/grapheme/grapheme_string.c

+24
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,9 @@ PHP_FUNCTION(grapheme_levenshtein)
10321032
intl_error_set_code(NULL, ustatus1);
10331033

10341034
intl_error_set_custom_msg(NULL, "Error on ubrk_setText on ustring1", 0);
1035+
if (ustring2) {
1036+
efree(ustring2);
1037+
}
10351038
if (ustring1) {
10361039
efree(ustring1);
10371040
}
@@ -1046,6 +1049,9 @@ PHP_FUNCTION(grapheme_levenshtein)
10461049
if (ustring2) {
10471050
efree(ustring2);
10481051
}
1052+
if (ustring1) {
1053+
efree(ustring1);
1054+
}
10491055
RETURN_FALSE;
10501056
}
10511057

@@ -1079,11 +1085,29 @@ PHP_FUNCTION(grapheme_levenshtein)
10791085
if (U_FAILURE(ustatus2)) {
10801086
intl_error_set_code(NULL, ustatus2);
10811087
intl_error_set_custom_msg(NULL, "Error usearch_open", 0);
1088+
ubrk_close(bi1);
1089+
ubrk_close(bi2);
1090+
1091+
efree(ustring1);
1092+
efree(ustring2);
1093+
1094+
efree(p1);
1095+
efree(p2);
1096+
RETURN_FALSE;
10821097
}
10831098
usrch_pos = usearch_first(srch, &ustatus2);
10841099
if (U_FAILURE(ustatus2)) {
10851100
intl_error_set_code(NULL, ustatus2);
10861101
intl_error_set_custom_msg(NULL, "Error usearch_first", 0);
1102+
ubrk_close(bi1);
1103+
ubrk_close(bi2);
1104+
1105+
efree(ustring1);
1106+
efree(ustring2);
1107+
1108+
efree(p1);
1109+
efree(p2);
1110+
RETURN_FALSE;
10871111
}
10881112
usearch_close(srch);
10891113

0 commit comments

Comments
 (0)