diff options
author | tamasmeszaros <meszaros.q@gmail.com> | 2019-06-02 21:02:27 +0300 |
---|---|---|
committer | tamasmeszaros <meszaros.q@gmail.com> | 2019-06-02 21:02:27 +0300 |
commit | 15620a2fc253b09ae7cb6c741a7430a69ff55db3 (patch) | |
tree | 7df483cc7b9e43c8d1236f9a3d376bce83829aae /src | |
parent | 916016f2d4bf2e183e45ebddc85e708e1eadc821 (diff) |
Fix unclosed file after export.
Diffstat (limited to 'src')
-rw-r--r-- | src/libslic3r/Zipper.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libslic3r/Zipper.cpp b/src/libslic3r/Zipper.cpp index afeaa8eca..b95f08e04 100644 --- a/src/libslic3r/Zipper.cpp +++ b/src/libslic3r/Zipper.cpp @@ -22,6 +22,7 @@ class Zipper::Impl { public: mz_zip_archive arch; std::string m_zipname; + FILE *cfile = nullptr; static std::string get_errorstr(mz_zip_error mz_err) { @@ -124,15 +125,15 @@ Zipper::Zipper(const std::string &zipfname, e_compression compression) memset(&m_impl->arch, 0, sizeof(m_impl->arch)); - FILE *f = boost::nowide::fopen(zipfname.c_str(), "wb"); + m_impl->cfile = boost::nowide::fopen(zipfname.c_str(), "wb"); - if (f == nullptr) { + if (m_impl->cfile == nullptr) { m_impl->arch.m_last_error = MZ_ZIP_FILE_OPEN_FAILED; m_impl->blow_up(); } // Initialize the archive data - if(!mz_zip_writer_init_cfile(&m_impl->arch, f, 0)) + if(!mz_zip_writer_init_cfile(&m_impl->arch, m_impl->cfile, 0)) m_impl->blow_up(); } @@ -151,6 +152,8 @@ Zipper::~Zipper() // The file should be closed no matter what... if(!mz_zip_writer_end(&m_impl->arch)) BOOST_LOG_TRIVIAL(error) << m_impl->formatted_errorstr(); + + if(m_impl->cfile) fclose(m_impl->cfile); } Zipper::Zipper(Zipper &&m): |