On I/O errors when opening a file, use wtap_close() to clean up, to make
authorGuy Harris <guy@alum.mit.edu>
Wed, 26 Dec 2012 11:59:47 +0000 (11:59 -0000)
committerGuy Harris <guy@alum.mit.edu>
Wed, 26 Dec 2012 11:59:47 +0000 (11:59 -0000)
sure we clean up everything.

svn path=/trunk/; revision=46773

wiretap/file_access.c

index 4706035e77b807f748ba49f4a4b4375491c964ca..c63f538c2f1ba30a33da1b89951bc33c8fc48d3b 100644 (file)
@@ -365,10 +365,7 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
                   Initialize the data offset while we're at it. */
                if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
                        /* I/O error - give up */
-                       if (wth->random_fh != NULL)
-                               file_close(wth->random_fh);
-                       file_close(wth->fh);
-                       g_free(wth);
+                       wtap_close(wth);
                        return NULL;
                }
 
@@ -376,10 +373,7 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info,
 
                case -1:
                        /* I/O error - give up */
-                       if (wth->random_fh != NULL)
-                               file_close(wth->random_fh);
-                       file_close(wth->fh);
-                       g_free(wth);
+                       wtap_close(wth);
                        return NULL;
 
                case 0: