From 8bc1530b2d27ad060ee53804fbbca677c57b7f71 Mon Sep 17 00:00:00 2001 From: Chris Hennick Date: Thu, 4 May 2023 10:23:55 -0700 Subject: [PATCH] Bug fix --- src/write.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/write.rs b/src/write.rs index 5e5c03a3..91f3f5ea 100644 --- a/src/write.rs +++ b/src/write.rs @@ -498,8 +498,8 @@ impl ZipWriter { /// Removes the file currently being written from the archive. pub fn abort_file(&mut self) -> ZipResult<()> { - self.files_by_name - .remove(&*self.files.pop().unwrap().file_name); + let last_file = self.files.pop().ok_or(ZipError::FileNotFound)?; + self.files_by_name.remove(&last_file.file_name); let make_plain_writer = self .inner .prepare_switch_to(CompressionMethod::Stored, None)?;