summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-02-02 22:51:34 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-02-02 22:51:34 (GMT)
commit93368182a239f462a001ca5690353ec93512d6ac (patch)
treec10007453f6d491b9793b70f0737114b4df8d3d3 /Objects
parent9f92a2b5a1dc2ec237ca1a744e3774635192cb33 (diff)
downloadcpython-93368182a239f462a001ca5690353ec93512d6ac.zip
cpython-93368182a239f462a001ca5690353ec93512d6ac.tar.gz
cpython-93368182a239f462a001ca5690353ec93512d6ac.tar.bz2
Merged revisions 77918 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r77918 | antoine.pitrou | 2010-02-02 23:47:00 +0100 (mar., 02 févr. 2010) | 10 lines Merged revisions 77916 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r77916 | antoine.pitrou | 2010-02-02 23:36:17 +0100 (mar., 02 févr. 2010) | 4 lines Issue #7385: Fix a crash in `MemoryView_FromObject` when `PyObject_GetBuffer` fails. Patch by Florent Xicluna. ........ ................
Diffstat (limited to 'Objects')
-rw-r--r--Objects/memoryobject.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
index 7acd569..e92a771 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -76,6 +76,7 @@ PyObject *
PyMemoryView_FromObject(PyObject *base)
{
PyMemoryViewObject *mview;
+ Py_buffer view;
if (!PyObject_CheckBuffer(base)) {
PyErr_SetString(PyExc_TypeError,
@@ -84,20 +85,17 @@ PyMemoryView_FromObject(PyObject *base)
return NULL;
}
- mview = (PyMemoryViewObject *)
- PyObject_GC_New(PyMemoryViewObject, &PyMemoryView_Type);
- if (mview == NULL)
+ if (PyObject_GetBuffer(base, &view, PyBUF_FULL_RO) < 0)
return NULL;
- mview->base = NULL;
- if (PyObject_GetBuffer(base, &(mview->view), PyBUF_FULL_RO) < 0) {
- Py_DECREF(mview);
+ mview = (PyMemoryViewObject *)PyMemoryView_FromBuffer(&view);
+ if (mview == NULL) {
+ PyBuffer_Release(&view);
return NULL;
}
mview->base = base;
Py_INCREF(base);
- _PyObject_GC_TRACK(mview);
return (PyObject *)mview;
}