From: David Levine Date: Sun, 26 Oct 2014 01:41:55 +0000 (-0500) Subject: Fixed memory leak in do_name() when multiple dates are parsed. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/2b5979253c1091073f132df6f17ec36886ade150 Fixed memory leak in do_name() when multiple dates are parsed. --- 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;