bsdgrep: use calloc where appropriate in grep's tre-fastmatch
Also apply style(9) to a related NULL check. Submitted by: Kyle Evans <kevans91 at ksu.edu> (D10098)
This commit is contained in:
parent
2f86d4b001
commit
e0780d5479
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=317700
@ -630,7 +630,7 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *pat, size_t n,
|
||||
if (escaped)
|
||||
{
|
||||
if (!_escmap)
|
||||
_escmap = malloc(n * sizeof(bool));
|
||||
_escmap = calloc(n, sizeof(bool));
|
||||
if (!_escmap)
|
||||
{
|
||||
free(tmp);
|
||||
@ -714,8 +714,8 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *pat, size_t n,
|
||||
{
|
||||
if (fg->wescmap != NULL)
|
||||
{
|
||||
fg->escmap = malloc(fg->len * sizeof(bool));
|
||||
if (!fg->escmap)
|
||||
fg->escmap = calloc(fg->len, sizeof(bool));
|
||||
if (fg->escmap != NULL)
|
||||
{
|
||||
tre_free_fast(fg);
|
||||
return REG_ESPACE;
|
||||
|
Loading…
Reference in New Issue
Block a user