fix: ensure iframe cleanup in getUntaintedPrototype on error or early return#1770
fix: ensure iframe cleanup in getUntaintedPrototype on error or early return#1770heathdutton wants to merge 1 commit intorrweb-io:masterfrom
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a resource leak where temporary iframes created to access untainted prototypes were not always properly cleaned up. The fix ensures the iframe is removed from the DOM in all exit paths.
Key Changes:
- Moved iframe variable declaration outside try block to make it accessible in finally block
- Replaced inline cleanup with a finally block that executes regardless of how the function exits
- Added safety check for parentNode existence before attempting removal
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #1627
The
getUntaintedPrototypefunction creates a temporary iframe to get clean prototypes, but fails to remove it when:contentWindowis null (early return)This adds a
finallyblock to ensure the iframe is always cleaned up.