-
-
Notifications
You must be signed in to change notification settings - Fork 736
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
ICU-22475 Fix double free in Locale under OOM #2567
Conversation
5ff474b
to
c36efd1
Compare
Notice: the branch changed across the force-push!
~ Your Friendly Jira-GitHub PR Checker Bot |
icu4c/source/test/cintltst/cloctst.c
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Outdated
@@ -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. |
There was a problem hiding this comment.
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?)
icu4c/source/test/cintltst/cloctst.c
Outdated
@@ -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); |
There was a problem hiding this comment.
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()
cea4669
to
3bf520c
Compare
Hooray! The files in the branch are the same across the force-push. 😃 ~ Your Friendly Jira-GitHub PR Checker Bot |
There was a problem hiding this 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
2c0f335
to
9668c7c
Compare
Hooray! The files in the branch are the same across the force-push. 😃 ~ Your Friendly Jira-GitHub PR Checker Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
The comments was changed to make it clear it is from the destructor of t.
Checklist