mirror of
https://github.com/git/git.git
synced 2024-10-28 04:49:43 +01:00
grep: fix leaking grep pattern
When creating a pattern via `create_grep_pat()` we allocate the pattern member of the structure regardless of the token type. But later, when we try to free the structure, we free the pattern member conditionally on the token type and thus leak memory. Plug this leak. The leak is exposed by t7814, but plugging it alone does not make the whole test suite pass. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
f8d2ca7246
commit
6d82437a47
1 changed files with 1 additions and 1 deletions
2
grep.c
2
grep.c
|
@ -843,11 +843,11 @@ static void free_grep_pat(struct grep_pat *pattern)
|
|||
free_pcre2_pattern(p);
|
||||
else
|
||||
regfree(&p->regexp);
|
||||
free(p->pattern);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
free(p->pattern);
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue