-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
gh-130567: Remove optimistic allocation in locale.strxfrm() #137143
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
Conversation
On modern systems, the result of wcsxfrm() is much larger the size of the input string (from 4+2*n on Windows to 4+5*n on Linux for simple ASCII strings), so optimistic allocation of the buffer of the same size never works.
Modules/_localemodule.c
Outdated
| goto exit; | ||
| } | ||
|
|
||
| /* assume no change in size, first */ |
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.
The comment should be updated to match changed code.
|
If this is a bug fix, it needs a NEWS entry. If the bug will be fixed in other way -- it is just cleanup and minor optimization not worth a NEWS entry. |
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.
This does not fix the bug; macOS raises EINVAL in wcsxfrm(NULL, s, 0) on the Czech and Chinese strings.
So, it's just cleanup and minor optimization.
|
Actually, optimistic allocation works if the locale was not set or set to "C". But why would you use |
|
This PR should fix a crash discussed in #130567 (comment). So this is a bug fix. If we are not going to backport it, we need another PR to fix it. |
|
Let's backport it [edit: to 3.14.1], even if can't reproduce the corruption on my system. |
|
Created a simpler PR #138940 for the fix. |
|
Do you want to update this one? |
On modern systems, the result of wcsxfrm() is much larger the size of the input string (from 4+2n on Windows to 4+5n on Linux for simple ASCII strings), so optimistic allocation of the buffer of the same size never works.