Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick port amf #5068

Merged
merged 14 commits into from
Mar 21, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
throw an exception if bad zip file
  • Loading branch information
lordofhyphens committed Mar 21, 2021
commit 648bc732af8bdcc8c35955470d7055618e973c04
5 changes: 4 additions & 1 deletion xs/src/libslic3r/miniz_extension.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <exception>

#include "miniz_extension.hpp"
#include "Exception.hpp"

#if defined(_MSC_VER) || defined(__MINGW64__)
#include "boost/nowide/cstdio.hpp"
Expand Down Expand Up @@ -36,11 +37,13 @@ bool open_zip(mz_zip_archive *zip, const char *fname, bool isread)
if (isread)
{
res = mz_zip_reader_init_cfile(zip, f, 0, 0);
if (!res)
if (!res) {
// if we get here it means we tried to open a non-zip file
// we need to close the file here because the call to mz_zip_get_cfile() made into close_zip() returns a null pointer
// see: https://github.com/prusa3d/PrusaSlicer/issues/3536
fclose(f);
throw Slic3r::FileIOError("Tried to open a non-zip file.");
}
}
else
res = mz_zip_writer_init_cfile(zip, f, 0);
Expand Down