mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-114685: Check flags in PyObject_GetBuffer() (GH-114707)
PyObject_GetBuffer() now raises a SystemError if called with PyBUF_READ or PyBUF_WRITE as flags. These flags should only be used with the PyMemoryView_* C API.
This commit is contained in:
parent
7a93db4425
commit
b7688ef71e
4 changed files with 19 additions and 2 deletions
|
|
@ -425,6 +425,12 @@ PyObject_AsWriteBuffer(PyObject *obj,
|
|||
int
|
||||
PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags)
|
||||
{
|
||||
if (flags != PyBUF_SIMPLE) { /* fast path */
|
||||
if (flags == PyBUF_READ || flags == PyBUF_WRITE) {
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
PyBufferProcs *pb = Py_TYPE(obj)->tp_as_buffer;
|
||||
|
||||
if (pb == NULL || pb->bf_getbuffer == NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue