Skip to content

Commit

Permalink
Remove a duplicate unlink.
Browse files Browse the repository at this point in the history
In cf_export_specified_packets(), if the loop processing the packets
fails, we're going to go to the failure code, which will unlink the file
to which we were writing if we were writing to a temporary file, so we
don't need to unlink it before going there.

While we're at it, note why we don't report any error from
wtap_dump_close() in that case.
  • Loading branch information
guyharris committed May 22, 2021
1 parent 5450870 commit 1502615
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -4879,11 +4879,12 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
break;

case PSP_FAILED:
/* Error while saving.
If we're writing to a temporary file, remove it. */
if (fname_new != NULL)
ws_unlink(fname_new);
/* Error while saving. */
wtap_dump_close(pdh, &err, &err_info);
/*
* We don't report any error from closing; the error that caused
* process_specified_records() to fail has already been reported.
*/
goto fail;
}

Expand Down

0 comments on commit 1502615

Please sign in to comment.