Only call wtap_dump_close() if we have an open file.

We can have a situation where a file only contains a valid file header
without any packages, so this will avoid a crash.

svn path=/trunk/; revision=28602
This commit is contained in:
Stig Bjørlykke 2009-06-02 17:22:40 +00:00
parent 7e6d072ce7
commit fa71489b83
1 changed files with 2 additions and 2 deletions

View File

@ -1250,9 +1250,9 @@ main(int argc, char *argv[])
}
}
if (!wtap_dump_close(pdh, &err)) {
if (pdh && !wtap_dump_close(pdh, &err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n", filename,
fprintf(stderr, "editcap: Error closing %s: %s\n", filename,
wtap_strerror(err));
exit(2);