mirror of
https://github.com/python/cpython.git
synced 2026-06-28 03:41:13 +00:00
gh-151126: Fix missing memory errors in _interpretersmodule.c (#151624)
This commit is contained in:
parent
a00464bc33
commit
05225aa06a
2 changed files with 6 additions and 2 deletions
|
|
@ -0,0 +1,3 @@
|
|||
Fix a crash when sharing :class:`memoryview` objects between interpreters
|
||||
fails due to running out of memory. It now raises a proper
|
||||
:exc:`MemoryError`.
|
||||
|
|
@ -144,7 +144,7 @@ xibufferview_from_buffer(PyTypeObject *cls, Py_buffer *view, int64_t interpid)
|
|||
|
||||
Py_buffer *copied = PyMem_RawMalloc(sizeof(Py_buffer));
|
||||
if (copied == NULL) {
|
||||
return NULL;
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
/* This steals the view->obj reference */
|
||||
*copied = *view;
|
||||
|
|
@ -152,7 +152,7 @@ xibufferview_from_buffer(PyTypeObject *cls, Py_buffer *view, int64_t interpid)
|
|||
xibufferview *self = PyObject_Malloc(sizeof(xibufferview));
|
||||
if (self == NULL) {
|
||||
PyMem_RawFree(copied);
|
||||
return NULL;
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
PyObject_Init(&self->base, cls);
|
||||
*self = (xibufferview){
|
||||
|
|
@ -277,6 +277,7 @@ _pybuffer_shared(PyThreadState *tstate, PyObject *obj, _PyXIData_t *data)
|
|||
{
|
||||
struct xibuffer *view = PyMem_RawMalloc(sizeof(struct xibuffer));
|
||||
if (view == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return -1;
|
||||
}
|
||||
view->used = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue