Skip to content
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

Windows process username() potential memory leak in case of error #1047

Closed
giampaolo opened this issue May 3, 2017 · 1 comment
Closed

Comments

@giampaolo
Copy link
Owner

...because the C implementation is a mess and does not properly cleanup resources as it should (via goto). In detail it's the token handle which is freed only assuming the previous instructions succeed and never return:

CloseHandle(tokenHandle);

@giampaolo
Copy link
Owner Author

...also, Py_Unicode* return value is never checked, potentially leading to invalid data being returned:

#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 3
py_unicode = PyUnicode_DecodeLocaleAndSize(
fullName, _tcslen(fullName), "surrogateescape");
#else
py_unicode = PyUnicode_Decode(
fullName, _tcslen(fullName), Py_FileSystemDefaultEncoding, "replace");
#endif

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

No branches or pull requests

1 participant