Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICU-22475 Fix double free in Locale under OOM #2567

Merged
merged 1 commit into from
Aug 30, 2023

Conversation

FrankYFTang
Copy link
Contributor

Checklist
  • Required: Issue filed: https://unicode-org.atlassian.net/browse/ICU-22475
  • Required: The PR title must be prefixed with a JIRA Issue number.
  • Required: The PR description must include the link to the Jira Issue, for example by completing the URL in the first checklist item
  • Required: Each commit message must be prefixed with a JIRA Issue number.
  • Issue accepted (done by Technical Committee after discussion)
  • Tests included, if applicable
  • API docs and/or User Guide docs changed or added, if applicable

@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • icu4c/source/common/uloc_tag.cpp is now changed in the branch

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@FrankYFTang FrankYFTang changed the title ICU-22475 Try to add test case ICU-22475 Fix double free in Locale under OOM Aug 29, 2023
@@ -2508,6 +2508,9 @@ static void TestCanonicalization21749StackUseAfterScope(void)
input, u_errorName(status));
return;
}

status = U_ZERO_ERROR;
uloc_canonicalize("ti-defaultgR-lS-z-UK-0P", buffer, 256, &status);
Copy link
Member

Choose a reason for hiding this comment

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

Please use sizeof buffer instead of hardcoding 256.

Copy link
Member

Choose a reason for hiding this comment

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

yes, sizeof() or UPRV_LENGTHOF()

@@ -2093,11 +2093,13 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta
if (tagLen < newTagLength) {
uprv_free(tagBuf);
tagBuf = (char*)uprv_malloc(newTagLength + 1);
t->buf = tagBuf; // Change t->buf after the free and before
// return to avoid the second double free in
// the destructor.
Copy link
Member

Choose a reason for hiding this comment

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

Do you by the destructor mean ultag_close()? If so, I think it'd be clearer if you wrote that instead. (If not, what do you mean then?)

@@ -2508,6 +2508,9 @@ static void TestCanonicalization21749StackUseAfterScope(void)
input, u_errorName(status));
return;
}

status = U_ZERO_ERROR;
uloc_canonicalize("ti-defaultgR-lS-z-UK-0P", buffer, 256, &status);
Copy link
Member

Choose a reason for hiding this comment

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

yes, sizeof() or UPRV_LENGTHOF()

icu4c/source/common/uloc_tag.cpp Show resolved Hide resolved
FrankYFTang added a commit to FrankYFTang/icu that referenced this pull request Aug 29, 2023
@jira-pull-request-webhook
Copy link

Hooray! The files in the branch are the same across the force-push. 😃

~ Your Friendly Jira-GitHub PR Checker Bot

Copy link
Member

@markusicu markusicu left a comment

Choose a reason for hiding this comment

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

lgtm tnx, please squash again

waiting to see if Fredrik is happy

@jira-pull-request-webhook
Copy link

Hooray! The files in the branch are the same across the force-push. 😃

~ Your Friendly Jira-GitHub PR Checker Bot

Copy link
Member

@markusicu markusicu left a comment

Choose a reason for hiding this comment

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

lgtm

@FrankYFTang FrankYFTang dismissed roubert’s stale review August 30, 2023 19:35

The comments was changed to make it clear it is from the destructor of t.

@FrankYFTang FrankYFTang merged commit 35bae68 into unicode-org:main Aug 30, 2023
101 checks passed
@FrankYFTang FrankYFTang deleted the ICU-22475-doubleFree branch August 30, 2023 19:35
catamorphism pushed a commit to catamorphism/icu that referenced this pull request Nov 1, 2023
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.

3 participants