From 2b5979253c1091073f132df6f17ec36886ade150 Mon Sep 17 00:00:00 2001 From: David Levine Date: Sat, 25 Oct 2014 20:41:55 -0500 Subject: [PATCH] Fixed memory leak in do_name() when multiple dates are parsed. --- sbr/fmt_compile.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index 9cec16a6..21acb5c5 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -562,8 +562,11 @@ do_name(char *sp, int preprocess) if (cm->c_type & CT_ADDR) { CERROR("component used as both date and address"); } - cm->c_tws = (struct tws *) - mh_xcalloc ((size_t) 1, sizeof(*cm->c_tws)); + if (cm->c_tws) { + memset (cm->c_tws, 0, sizeof *cm->c_tws); + } else { + cm->c_tws = mh_xcalloc (1, sizeof *cm->c_tws); + } fp->f_type = preprocess; PUTCOMP(sp); cm->c_type |= CT_DATE; -- 2.56.0