From 9b0e550d7013204bf05c5c5e5ba02498ae1fdeb5 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 16 Sep 2012 12:22:29 +0200 Subject: [PATCH] More tests for freeing NULL pointers --- bacula/src/lib/message.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 24afdf19e3..c3ac172cb2 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -588,13 +588,18 @@ void close_msg(JCR *jcr) } free_memory(line); rem_temp_file: - /* Remove temp mail file */ - fclose(d->fd); - d->fd = NULL; - /* Exclude spaces in mail_filename */ - safer_unlink(d->mail_filename, MAIL_REGEX); - free_pool_memory(d->mail_filename); - d->mail_filename = NULL; + /* Remove temp file */ + if (d->fd) { + fclose(d->fd); + d->fd = NULL; + } + if (d->mail_filename) { + /* Exclude spaces in mail_filename */ + safer_unlink(d->mail_filename, MAIL_REGEX); + unlink(d->mail_filename); + free_pool_memory(d->mail_filename); + d->mail_filename = NULL; + } Dmsg0(850, "end mail or mail on error\n"); break; default: -- 2.39.5