Type
Title:
UniversalPackage leaves file stream open when a corrupt file is passed in
Created:
3/31/2021 8:12:35 AM by wldevries
Status:
closed on 3/31/2021 2:56:53 PM
Last pulled:
3/31/2021 2:56:53 PM
Description:
When using the constructor `UniversalPackage(string fileName)` on a corrupt zip file or a file that is not a zip file the constructor will crash and leave the file handle open. **Steps to reproduce** 1. Create a corrupt `.upack` file 2. Execute the following code ``` try { using (var upack = new UniversalPackage(packagePath)) { return upack.GetFullMetadata(); } } catch (InvalidDataException) { while (true) File.Delete(packagePath); } ``` **Expected result** I would expect the failing constructor to clean up the file handle making it possible to delete the file on failure. **Actual result** File handle is not released for corrupt packages. (it may be released after a long time by the garbage collector, I'm not sure)