Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-106844: Fix null-bytes handling in LCMapStringEx in _winapi#107832
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
zooba left a comment
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. Just be aware it won't backport cleanly to 3.11, and theLPCWSTR converter has a memory leak in that version and shouldn't be used.
serhiy-storchaka commentedAug 10, 2023
Before merging it I want to manually test it on Windows with large strings, and maybe add bigmem tests if it is feasible. |
| NULL,NULL,0); | ||
| if (dest_size==0) { | ||
| returnPyErr_SetFromWindowsErr(0); | ||
| if (dest_size <=0) { |
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.
It can return negative value. At least ifsrc_size is negative. But the second call returns 0 anyway.
| if (dest_size==0) { | ||
| returnPyErr_SetFromWindowsErr(0); | ||
| if (dest_size <=0) { | ||
| DWORDerror=GetLastError(); |
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.
Other code callsGetLastError() as early as possible, beforePyMem_Free(). Perhaps there is a reason of it.
| PyMem_Free(src_); | ||
| PyObject*ret=PyUnicode_FromWideChar(dest,nmapped); |
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.
It reduces the maximal total memory consumption if free this memorybefore allocating new memory inPyUnicode_FromWideChar().
miss-islington commentedAug 11, 2023
Thanks@serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
miss-islington commentedAug 11, 2023
Sorry,@serhiy-storchaka, I could not cleanly backport this to |
miss-islington commentedAug 11, 2023
Sorry,@serhiy-storchaka, I could not cleanly backport this to |
…-107832)* Strings with length from 2**31-1 to 2**32-2 always caused MemoryError, it doesn't matter how much memory is available.* Strings with length exactly 2**32-1 caused OSError.* Strings longer than 2**32-1 characters were truncated due to integer overflow bug.* Strings containing the null character were truncated at the first null character.Now strings longer than 2**31-1 characters caused OverflowError and the null character is allowed..(cherry picked from commit04cc014)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
bedevere-bot commentedAug 11, 2023
GH-107874 is a backport of this pull request to the3.12 branch. |
…-107832)* Strings with length from 2**31-1 to 2**32-2 always caused MemoryError, it doesn't matter how much memory is available.* Strings with length exactly 2**32-1 caused OSError.* Strings longer than 2**32-1 characters were truncated due to integer overflow bug.* Strings containing the null character were truncated at the first null character.Now strings longer than 2**31-1 characters caused OverflowError and the null character is allowed..(cherry picked from commit04cc014)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
bedevere-bot commentedAug 11, 2023
GH-107875 is a backport of this pull request to the3.11 branch. |
sobolevn commentedAug 11, 2023
Thanks for fixing this! 👍 |
…-107875)* Strings with length from 2**31-1 to 2**32-2 always caused MemoryError, it doesn't matter how much memory is available.* Strings with length exactly 2**32-1 caused OSError.* Strings longer than 2**32-1 characters were truncated due to integer overflow bug.Now strings longer than 2**31-1 characters caused OverflowError.(cherry picked from commit04cc014)
* Strings with length from 2**31-1 to 2**32-2 always caused MemoryError, it doesn't matter how much memory is available.* Strings with length exactly 2**32-1 caused OSError.* Strings longer than 2**32-1 characters were truncated due to integer overflow bug.* Strings containing the null character were truncated at the first null character.Now strings longer than 2**31-1 characters caused OverflowError and the null character is allowed.
…07874)* Strings with length from 2**31-1 to 2**32-2 always caused MemoryError, it doesn't matter how much memory is available.* Strings with length exactly 2**32-1 caused OSError.* Strings longer than 2**32-1 characters were truncated due to integer overflow bug.* Strings containing the null character were truncated at the first null character.Now strings longer than 2**31-1 characters caused OverflowError and the null character is allowed..(cherry picked from commit04cc014)
Uh oh!
There was an error while loading.Please reload this page.
Based on#106857 with some fixes.