ICU-23353 Fix double-delete in Region::cleanupRegionData#3922
Open
hirorogo wants to merge 1 commit intounicode-org:maint/maint-54from
Open
ICU-23353 Fix double-delete in Region::cleanupRegionData#3922hirorogo wants to merge 1 commit intounicode-org:maint/maint-54from
hirorogo wants to merge 1 commit intounicode-org:maint/maint-54from
Conversation
Nullify pointers after delete/uhash_close so that a repeated call to cleanupRegionData does not double-free the same allocations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
Could a maintainer please transition the Jira ticket ICU-23353 from New to Accepted? The |
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.
Summary
Region::cleanupRegionData()inregion.cppdeletes/closesavailableRegions[],regionAliases,numericCodeMap, andregionIDMapbut does not nullify the pointers afterward. If cleanup is called multiple times (e.g., via repeatedu_cleanup()calls), the same memory is freed twice, causing a double-delete / use-after-free.Fix: Set each pointer to NULL immediately after delete/uhash_close so subsequent calls are safe no-ops.
PoC
Output:
Test plan
u_cleanup()twice no longer crashes