Skip to content

Fix PresentationBuilder resource leak #25

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

Open
wants to merge 7 commits into
base: vNext
Choose a base branch
from

Conversation

Lotes
Copy link

@Lotes Lotes commented Jul 1, 2020

You need to dispose the stream. Otherwise when two parts use the same resource it will complain about multiple opened streams when package is in "UpdateMode". This change was done on top of Pullrequest #15.

@Lotes
Copy link
Author

Lotes commented Jul 2, 2020

One possible stacktrace... My fix closes about 12 leaks. I have only one path here.

 ---> System.IO.IOException: Entries cannot be opened multiple times in Update mode.
   at System.IO.Compression.ZipArchiveEntry.OpenInUpdateMode()
   at System.IO.Packaging.ZipStreamManager.Open(ZipArchiveEntry zipArchiveEntry, FileMode streamFileMode, FileAccess streamFileAccess)
   at System.IO.Packaging.ZipPackagePart.GetStreamCore(FileMode streamFileMode, FileAccess streamFileAccess)
   at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
   at OpenXmlPowerTools.PresentationBuilder.CopyExtendedPart(OpenXmlPart oldContentPart, OpenXmlPart newContentPart, XElement extendedReference, XName attributeName)
   at OpenXmlPowerTools.PresentationBuilder.CopyRelatedPartsForContentParts(PresentationDocument newDocument, OpenXmlPart oldContentPart, OpenXmlPart newContentPart, IEnumerable`1 newContent, List`1 images, List`1 mediaList)
   at OpenXmlPowerTools.PresentationBuilder.AppendSlides(PresentationDocument sourceDocument, PresentationDocument newDocument, Int32 start, Int32 count, Boolean keepMaster, List`1 images, SlideMasterPart currentMasterPart, List`1 mediaList)
   at OpenXmlPowerTools.PresentationBuilder.BuildPresentation(List`1 sources, PresentationDocument output)
   at OpenXmlPowerTools.PresentationBuilder.BuildPresentation(List`1 sources)

@hbnrmx
Copy link

hbnrmx commented Mar 22, 2023

@Lotes thanks for saving me some work with your fix!

Since this fork doesn't seem to be maintained, is there any chance we could direct your fix towards another actively maintained fork?

Looking over the forks, I see that https://github.com/Codeuctivity/OpenXmlPowerTools might be a candidate. @stesee could you shed some light on the status of that fork and its willingness to accept other PRs? Thank you!

@stesee
Copy link

stesee commented Mar 22, 2023

Status: Pet Project
Would I accept PRs? Sure. As long as they add tests for new functionality and the effort fits into pet project budget.

@hbnrmx
Copy link

hbnrmx commented Apr 4, 2023

FYI, we decided to go a different route but I appreciate your quick responses. Thank you guys!

huan086 pushed a commit to huan086/Open-Xml-PowerTools that referenced this pull request Sep 17, 2024
…ocumentFormat.OpenXml-2.14.0

Bump DocumentFormat.OpenXml from 2.13.1 to 2.14.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants