mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-13 17:31:48 +08:00
#3536 - Fixed PrusaSlicer not closing the file when trying to open an invalid 3mf (actually any zip) file
This commit is contained in:
parent
cbe5132832
commit
c87e951da5
@ -26,8 +26,20 @@ bool open_zip(mz_zip_archive *zip, const char *fname, bool isread)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isread ? mz_zip_reader_init_cfile(zip, f, 0, 0)
|
bool res = false;
|
||||||
: mz_zip_writer_init_cfile(zip, f, 0);
|
if (isread)
|
||||||
|
{
|
||||||
|
res = mz_zip_reader_init_cfile(zip, f, 0, 0);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
res = mz_zip_writer_init_cfile(zip, f, 0);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool close_zip(mz_zip_archive *zip, bool isread)
|
bool close_zip(mz_zip_archive *zip, bool isread)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user