Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
serhiy-storchaka merged 6 commits intopython:mainfromserhiy-storchaka:issue-106844
Aug 11, 2023

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commentedAug 10, 2023
edited by bedevere-bot
Loading

Copy link
Member

@zoobazooba left a 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
Copy link
MemberAuthor

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) {
Copy link
MemberAuthor

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();
Copy link
MemberAuthor

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.

Comment on lines +1590 to +1591
PyMem_Free(src_);
PyObject*ret=PyUnicode_FromWideChar(dest,nmapped);
Copy link
MemberAuthor

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().

@serhiy-storchakaserhiy-storchaka merged commit04cc014 intopython:mainAug 11, 2023
@miss-islington
Copy link
Contributor

Thanks@serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry,@serhiy-storchaka, I could not cleanly backport this to3.12 due to a conflict.
Please backport usingcherry_picker on command line.
cherry_picker 04cc01453db2f0af72a06440831637f8bf512daf 3.12

@miss-islington
Copy link
Contributor

Sorry,@serhiy-storchaka, I could not cleanly backport this to3.11 due to a conflict.
Please backport usingcherry_picker on command line.
cherry_picker 04cc01453db2f0af72a06440831637f8bf512daf 3.11

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull requestAug 11, 2023
…-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
Copy link

GH-107874 is a backport of this pull request to the3.12 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.12only security fixes labelAug 11, 2023
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull requestAug 11, 2023
…-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
Copy link

GH-107875 is a backport of this pull request to the3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11only security fixes labelAug 11, 2023
@sobolevn
Copy link
Member

Thanks for fixing this! 👍

serhiy-storchaka added a commit that referenced this pull requestAug 12, 2023
…-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)
zooba pushed a commit to zooba/cpython that referenced this pull requestAug 15, 2023
* 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.
Yhg1s pushed a commit that referenced this pull requestAug 16, 2023
…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)
@serhiy-storchakaserhiy-storchaka removed their assignmentSep 8, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@zoobazoobazooba approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@serhiy-storchaka@miss-islington@bedevere-bot@sobolevn@zooba

[8]ページ先頭

©2009-2025 Movatter.jp