mirror of
https://github.com/python/cpython.git
synced 2025-09-12 19:57:40 +00:00
[3.13] gh-126980: Fix bytearray.__buffer__
crash on PyBUF_{READ,WRITE}
(GH-126981) (#127023)
(cherry picked from commit 3932e1db53
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
dd222a4d47
commit
3fae84fe58
3 changed files with 15 additions and 4 deletions
|
@ -44,15 +44,15 @@ _getbytevalue(PyObject* arg, int *value)
|
|||
static int
|
||||
bytearray_getbuffer(PyByteArrayObject *obj, Py_buffer *view, int flags)
|
||||
{
|
||||
void *ptr;
|
||||
if (view == NULL) {
|
||||
PyErr_SetString(PyExc_BufferError,
|
||||
"bytearray_getbuffer: view==NULL argument is obsolete");
|
||||
return -1;
|
||||
}
|
||||
ptr = (void *) PyByteArray_AS_STRING(obj);
|
||||
/* cannot fail if view != NULL and readonly == 0 */
|
||||
(void)PyBuffer_FillInfo(view, (PyObject*)obj, ptr, Py_SIZE(obj), 0, flags);
|
||||
void *ptr = (void *) PyByteArray_AS_STRING(obj);
|
||||
if (PyBuffer_FillInfo(view, (PyObject*)obj, ptr, Py_SIZE(obj), 0, flags) < 0) {
|
||||
return -1;
|
||||
}
|
||||
obj->ob_exports++;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue