Skip to content

Commit a54cc2b

Browse files
authored
Merge pull request libgit2#6382 from csware/fix_mem_leak
Fix memory leak
2 parents b075bda + bb65da7 commit a54cc2b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/util/regexp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ int git_regexp_match(const git_regexp *r, const char *string)
108108
data = pcre2_match_data_create(1, NULL);
109109
GIT_ERROR_CHECK_ALLOC(data);
110110

111-
if ((error = pcre2_match(*r, (const unsigned char *) string, strlen(string),
112-
0, 0, data, NULL)) < 0)
111+
error = pcre2_match(*r, (const unsigned char *) string, strlen(string), 0, 0, data, NULL);
112+
pcre2_match_data_free(data);
113+
if (error < 0)
113114
return (error == PCRE2_ERROR_NOMATCH) ? GIT_ENOTFOUND : GIT_EINVALIDSPEC;
114115

115-
pcre2_match_data_free(data);
116116
return 0;
117117
}
118118

0 commit comments

Comments
 (0)