Close the XsbReader when resolveHandle meets an unhandled file type - #108
Merged
Merged
Conversation
SchemaTypeSystemImpl.resolveHandle opens an XsbReader, then dispatches on the file type it finds. Each finishLoadingXxx() closes the reader in a finally, but the default arm throws IllegalStateException without closing, leaking the underlying .xsb stream. The arm is reachable: FILETYPE_SCHEMAPOINTER is a file type the compiler writes but this switch does not handle, as is any type read from a corrupt or crafted .xsb. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SchemaTypeSystemImpl.resolveHandleconstructs anXsbReader— which opens the.xsbresource stream — and then dispatches on the file type it read. EveryfinishLoadingXxx()closes the reader in afinally, but thedefault:arm throwsIllegalStateExceptionwithout closing, leaking the stream.That arm is reachable in practice:
FILETYPE_SCHEMAPOINTERis a file type the compiler writes (savePointerFile) but this switch does not handle, as is any file type read out of a corrupt or crafted.xsb.Added
ResolveHandleFileTypeTest, which serves a well-formed pointer.xsbthrough a stubResourceLoaderand asserts the stream is closed. It fails on trunk and passes with this change.🤖 Generated with Claude Code