Shockah / Nickel

A modding API / mod loader for the game Cobalt Core.
Apache License 2.0
3 stars 5 forks source link

Robustify `StreamExt::ToMemoryStream` #76

Closed Fayti1703 closed 8 months ago

Fayti1703 commented 8 months ago

Previously, if an error occurred while the stream was being copied into memory, the open Stream would leak, even if the method was employed in a way that would transfer ownership of the Stream into it.

This PR corrects this issue by ensuring that the passed stream is always closed if the second parameter is true, even if an exception is thrown.