Skip to content

ICU-23508 Rebind UText chunk contents after deep clone - #4181

Merged
markusicu merged 1 commit into
unicode-org:mainfrom
Trithem90:fix-icu-23508
Sep 21, 2026
Merged

markusicu merged 1 commit into
unicode-org:mainfrom
Trithem90:fix-icu-23508

Conversation

@Trithem90

Copy link
Copy Markdown
Contributor

Summary

Fixes ICU-23508.

Deep cloning a UText backed by UnicodeString or UChar* replaced
dest->context with newly owned storage but left dest->chunkContents
pointing to the source storage.

This could cause a deep clone to continue reading from the original buffer
instead of its independent copy.

Fix

Rebind dest->chunkContents to the newly allocated backing storage in:

  • unistrTextClone()
  • ucstrTextClone()

Tests

Added UTextTest::Ticket23508() covering both affected providers.

The regression test:

  • fails for both UChar* and UnicodeString without the fix;
  • passes for both with the fix;
  • and the full utility/UTextTest suite passes.

Tested with ICU 79.0.1.

@CLAassistant

CLAassistant commented Sep 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@markusicu markusicu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm2 tnx

@markusicu
markusicu merged commit 155bf3a into unicode-org:main Sep 21, 2026
98 checks passed
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.

4 participants