summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-02-02 22:47:00 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-02-02 22:47:00 (GMT)
commit05b7c5644c9c7a5e7b656fc241e45ff171c16d84 (patch)
treed07ae9c29a199cb8c6a204668c1a9ac13a6bd07f /Objects
parentb1f7b7bef58a2e60eeb61180b400e13f487e139f (diff)
downloadcpython-05b7c5644c9c7a5e7b656fc241e45ff171c16d84.zip
cpython-05b7c5644c9c7a5e7b656fc241e45ff171c16d84.tar.gz
cpython-05b7c5644c9c7a5e7b656fc241e45ff171c16d84.tar.bz2
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;
}