]> sjero.net Git - wget/blobdiff - src/init.c
Check for fclose errors.
[wget] / src / init.c
index d5f9a4f09bdb9c0d447a59b0333df96a59555915..4188ca16c1b66795f896baa771a6caa836af2437 100644 (file)
@@ -30,6 +30,7 @@ shall include the source code for the parts of OpenSSL used as well
 as that of the covered work.  */
 
 #include "wget.h"
+#include "exits.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -1675,8 +1676,16 @@ cleanup (void)
 {
   /* Free external resources, close files, etc. */
 
+  /* Close WARC file. */
+  if (opt.warc_filename != 0)
+    warc_close ();
+
+  log_close ();
+
   if (output_stream)
-    fclose (output_stream);
+    if (fclose (output_stream) == EOF)
+      inform_exit_status (CLOSEFAILED);
+
   /* No need to check for error because Wget flushes its output (and
      checks for errors) after any data arrives.  */
 
@@ -1696,6 +1705,9 @@ cleanup (void)
   host_cleanup ();
   log_cleanup ();
 
+  for (i = 0; i < nurl; i++)
+    xfree (url[i]);
+
   {
     extern acc_t *netrc_list;
     free_netrc (netrc_list);