Merge branch 'git-2.37'
[TortoiseGit.git] / ext / libgit2-0001-Fix-memory-leak.patch
blob3018fb4239a7c01cf1e68a1d5c3593995d4a13b6
1 From bb65da7d5cd9fe7d51776dac34af7bbf3a59b7c4 Mon Sep 17 00:00:00 2001
2 From: Sven Strickroth <email@cs-ware.de>
3 Date: Sun, 14 Aug 2022 21:37:49 +0200
4 Subject: [PATCH] Fix memory leak
6 Signed-off-by: Sven Strickroth <email@cs-ware.de>
7 ---
8 src/util/regexp.c | 6 +++---
9 1 file changed, 3 insertions(+), 3 deletions(-)
11 diff --git a/src/util/regexp.c b/src/util/regexp.c
12 index 2569dea0a..08700882b 100644
13 --- a/src/util/regexp.c
14 +++ b/src/util/regexp.c
15 @@ -108,11 +108,11 @@ int git_regexp_match(const git_regexp *r, const char *string)
16 data = pcre2_match_data_create(1, NULL);
17 GIT_ERROR_CHECK_ALLOC(data);
19 - if ((error = pcre2_match(*r, (const unsigned char *) string, strlen(string),
20 - 0, 0, data, NULL)) < 0)
21 + error = pcre2_match(*r, (const unsigned char *) string, strlen(string), 0, 0, data, NULL);
22 + pcre2_match_data_free(data);
23 + if (error < 0)
24 return (error == PCRE2_ERROR_NOMATCH) ? GIT_ENOTFOUND : GIT_EINVALIDSPEC;
26 - pcre2_match_data_free(data);
27 return 0;
30 --
31 2.37.2.windows.2