Skip to content

Commit

Permalink
pythongh-126594: Fix typeobject.c wrap_buffer() cast
Browse files Browse the repository at this point in the history
Reject flags smaller than INT_MIN.
  • Loading branch information
vstinner committed Nov 12, 2024
1 parent 6b2a196 commit 019df14
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -9314,13 +9314,13 @@ wrap_buffer(PyObject *self, PyObject *args, void *wrapped)
if (flags == -1 && PyErr_Occurred()) {
return NULL;
}
if (flags > INT_MAX) {
if (flags > INT_MAX || flags < INT_MIN) {
PyErr_SetString(PyExc_OverflowError,
"buffer flags too large");
return NULL;
}

return _PyMemoryView_FromBufferProc(self, Py_SAFE_DOWNCAST(flags, Py_ssize_t, int),
return _PyMemoryView_FromBufferProc(self, (int)flags,
(getbufferproc)wrapped);
}

Expand Down

0 comments on commit 019df14

Please sign in to comment.