8000 [Skip Issue] Replace dead code with an assertion in winreg.c by ZackerySpytz · Pull Request #10028 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[Skip Issue] Replace dead code with an assertion in winreg.c #10028

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

Merged
merged 2 commits into from
Nov 8, 2018

Conversation

ZackerySpytz
Copy link
Contributor

No description provided.

@serhiy-storchaka
Copy link
Member

Actually PyUnicode_AsUnicodeAndSize() shouldn't fail here. It could fail at the first iteration.

@serhiy-storchaka
Copy link
Member

I would rather replace the check with an assert.

@ZackerySpytz
Copy link
Contributor Author

It seems fragile to rely wholly on the previous PyUnicode_AsUnicodeAndSize() calls. It would be safest to keep the NULL check.

@serhiy-storchaka
Copy link
Member

We already rely on the previous PyUnicode_AsUnicodeAndSize() calls. If the second call can return a different pointer, it can return also a different size. And it that case we will get a buffer overwriting.

I suggest to add two asserts, for pointer and for length.

@ZackerySpytz ZackerySpytz changed the title [Skip Issue] Fix a possible memory leak in winreg.c [Skip Issue] Replace dead code with an assertion in winreg.c Nov 1, 2018
@ZackerySpytz
Copy link
Contributor Author

@serhiy-storchaka Thank you for your remarks, Serhiy. I've replaced the check with an assertion.

@serhiy-storchaka serhiy-storchaka merged commit 5d95312 into python:master Nov 8, 2018
@serhiy-storchaka serhiy-storchaka removed the type-bug An unexpected behavior, bug, or error label Nov 8, 2018
@Carole1
Copy link
Carole1 commented Nov 8, 2018

with these code problems, I'm not ready yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0