]> git.sur5r.net Git - bacula/bacula/commitdiff
More tests for freeing NULL pointers
authorKern Sibbald <kern@sibbald.com>
Sun, 16 Sep 2012 10:22:29 +0000 (12:22 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:50:59 +0000 (14:50 +0200)
bacula/src/lib/message.c

index 24afdf19e32beb734dd5daa4398f50d229d5fc84..c3ac172cb291d3cff172ff55900f82ff0b192500 100644 (file)
@@ -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: