Skip to content

Use-after-free in object::memoryview for the format description #1501

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

Closed
aguinet opened this issue Aug 26, 2018 · 1 comment
Closed

Use-after-free in object::memoryview for the format description #1501

aguinet opened this issue Aug 26, 2018 · 1 comment

Comments

@aguinet
Copy link

aguinet commented Aug 26, 2018

Issue description

object:memoryview pass a temporary buffer for the format to PyMemoryView_FromBuffer. By reading the source code of this function, it does not "strdup" this format string, so it supposes it's always valid.

It is not really clear in the documentation how ownership works for the format. I figured this out because I had broken format issues with memory views in https://github.com/aguinet/dragonffi/ . A temporary fix by using strdup here https://github.com/aguinet/dragonffi/blob/master/third-party/pybind11/pytypes.h#L1255 fix the problem, but leaks memory.

Reproducible example code

Hard to reproduce, as it's an use-after-free problem. Basically, creates a memoryview with a given format, and in some cases the format within the Python object will be wrong!

@YannickJadoul
Copy link
Collaborator

I think this was fixed by #2223? If not, please reopen!

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

No branches or pull requests

2 participants