From 08e1b25b0ec17d4312f838efc6f910b64900b009 Mon Sep 17 00:00:00 2001 From: "Michael W. Bombardieri" Date: Wed, 29 Nov 2017 08:11:22 -0500 Subject: scanner: use calloc to allocate new filter memory --- src/filter.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/filter.c b/src/filter.c index ccdcdd6..a7e69ec 100644 --- a/src/filter.c +++ b/src/filter.c @@ -47,10 +47,9 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd, va_list ap; /* allocate and initialize new filter */ - f = malloc(sizeof(struct filter)); + f = calloc(sizeof(struct filter), 1); if (!f) - flexerror(_("malloc failed (f) in filter_create_ext")); - memset (f, 0, sizeof (*f)); + flexerror(_("calloc failed (f) in filter_create_ext")); f->filter_func = NULL; f->extra = NULL; f->next = NULL; @@ -100,10 +99,9 @@ struct filter *filter_create_int (struct filter *chain, struct filter *f; /* allocate and initialize new filter */ - f = malloc(sizeof(struct filter)); + f = calloc(sizeof(struct filter), 1); if (!f) - flexerror(_("malloc failed in filter_create_int")); - memset (f, 0, sizeof (*f)); + flexerror(_("calloc failed in filter_create_int")); f->next = NULL; f->argc = 0; f->argv = NULL; -- cgit v1.2.3