From: Kern Sibbald Date: Sun, 16 Sep 2012 10:22:29 +0000 (+0200) Subject: More tests for freeing NULL pointers X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9781c5b6c452b1351fd65d306fdf9a016e9a7866;p=bacula%2Fbacula More tests for freeing NULL pointers --- 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: