Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
526e421b
Kaydet (Commit)
526e421b
authored
Şub 02, 2010
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #7385: Fix a crash in `MemoryView_FromObject` when
`PyObject_GetBuffer` fails. Patch by Florent Xicluna.
üst
1b93fc10
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
7 deletions
+103
-7
NEWS
Misc/NEWS
+3
-0
_testcapimodule.c
Modules/_testcapimodule.c
+95
-0
memoryobject.c
Objects/memoryobject.c
+5
-7
No files found.
Misc/NEWS
Dosyayı görüntüle @
526e421b
...
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 3?
...
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 3?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #7385: Fix a crash in `MemoryView_FromObject` when
`PyObject_GetBuffer` fails. Patch by Florent Xicluna.
- Issue #7819: Check sys.call_tracing() arguments types.
- Issue #7819: Check sys.call_tracing() arguments types.
- Issue #7788: Fix an interpreter crash produced by deleting a list
- Issue #7788: Fix an interpreter crash produced by deleting a list
...
...
Modules/_testcapimodule.c
Dosyayı görüntüle @
526e421b
...
@@ -283,6 +283,100 @@ test_lazy_hash_inheritance(PyObject* self)
...
@@ -283,6 +283,100 @@ test_lazy_hash_inheritance(PyObject* self)
}
}
/* Issue #7385: Check that memoryview() does not crash
* when bf_getbuffer returns an error
*/
static
int
broken_buffer_getbuffer
(
PyObject
*
self
,
Py_buffer
*
view
,
int
flags
)
{
PyErr_SetString
(
TestError
,
"test_broken_memoryview: expected error in bf_getbuffer"
);
return
-
1
;
}
static
PyBufferProcs
memoryviewtester_as_buffer
=
{
0
,
/* bf_getreadbuffer */
0
,
/* bf_getwritebuffer */
0
,
/* bf_getsegcount */
0
,
/* bf_getcharbuffer */
(
getbufferproc
)
broken_buffer_getbuffer
,
/* bf_getbuffer */
0
,
/* bf_releasebuffer */
};
static
PyTypeObject
_MemoryViewTester_Type
=
{
PyObject_HEAD_INIT
(
NULL
)
0
,
/* Number of items for varobject */
"memoryviewtester"
,
/* Name of this type */
sizeof
(
PyObject
),
/* Basic object size */
0
,
/* Item size for varobject */
(
destructor
)
PyObject_Del
,
/* tp_dealloc */
0
,
/* tp_print */
0
,
/* tp_getattr */
0
,
/* tp_setattr */
0
,
/* tp_compare */
0
,
/* tp_repr */
0
,
/* tp_as_number */
0
,
/* tp_as_sequence */
0
,
/* tp_as_mapping */
0
,
/* tp_hash */
0
,
/* tp_call */
0
,
/* tp_str */
PyObject_GenericGetAttr
,
/* tp_getattro */
0
,
/* tp_setattro */
&
memoryviewtester_as_buffer
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_NEWBUFFER
,
/* tp_flags */
0
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
0
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
0
,
/* tp_descr_get */
0
,
/* tp_descr_set */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_alloc */
PyType_GenericNew
,
/* tp_new */
};
static
PyObject
*
test_broken_memoryview
(
PyObject
*
self
)
{
PyObject
*
obj
=
PyObject_New
(
PyObject
,
&
_MemoryViewTester_Type
);
PyObject
*
res
;
if
(
obj
==
NULL
)
{
PyErr_Clear
();
PyErr_SetString
(
TestError
,
"test_broken_memoryview: failed to create object"
);
return
NULL
;
}
res
=
PyMemoryView_FromObject
(
obj
);
if
(
res
||
!
PyErr_Occurred
()){
PyErr_SetString
(
TestError
,
"test_broken_memoryview: memoryview() didn't raise an Exception"
);
Py_XDECREF
(
res
);
Py_DECREF
(
obj
);
return
NULL
;
}
PyErr_Clear
();
Py_DECREF
(
obj
);
Py_RETURN_NONE
;
}
/* Tests of PyLong_{As, From}{Unsigned,}Long(), and (#ifdef HAVE_LONG_LONG)
/* Tests of PyLong_{As, From}{Unsigned,}Long(), and (#ifdef HAVE_LONG_LONG)
PyLong_{As, From}{Unsigned,}LongLong().
PyLong_{As, From}{Unsigned,}LongLong().
...
@@ -1401,6 +1495,7 @@ static PyMethodDef TestMethods[] = {
...
@@ -1401,6 +1495,7 @@ static PyMethodDef TestMethods[] = {
{
"test_list_api"
,
(
PyCFunction
)
test_list_api
,
METH_NOARGS
},
{
"test_list_api"
,
(
PyCFunction
)
test_list_api
,
METH_NOARGS
},
{
"test_dict_iteration"
,
(
PyCFunction
)
test_dict_iteration
,
METH_NOARGS
},
{
"test_dict_iteration"
,
(
PyCFunction
)
test_dict_iteration
,
METH_NOARGS
},
{
"test_lazy_hash_inheritance"
,
(
PyCFunction
)
test_lazy_hash_inheritance
,
METH_NOARGS
},
{
"test_lazy_hash_inheritance"
,
(
PyCFunction
)
test_lazy_hash_inheritance
,
METH_NOARGS
},
{
"test_broken_memoryview"
,
(
PyCFunction
)
test_broken_memoryview
,
METH_NOARGS
},
{
"test_long_api"
,
(
PyCFunction
)
test_long_api
,
METH_NOARGS
},
{
"test_long_api"
,
(
PyCFunction
)
test_long_api
,
METH_NOARGS
},
{
"test_long_and_overflow"
,
(
PyCFunction
)
test_long_and_overflow
,
{
"test_long_and_overflow"
,
(
PyCFunction
)
test_long_and_overflow
,
METH_NOARGS
},
METH_NOARGS
},
...
...
Objects/memoryobject.c
Dosyayı görüntüle @
526e421b
...
@@ -76,6 +76,7 @@ PyObject *
...
@@ -76,6 +76,7 @@ PyObject *
PyMemoryView_FromObject
(
PyObject
*
base
)
PyMemoryView_FromObject
(
PyObject
*
base
)
{
{
PyMemoryViewObject
*
mview
;
PyMemoryViewObject
*
mview
;
Py_buffer
view
;
if
(
!
PyObject_CheckBuffer
(
base
))
{
if
(
!
PyObject_CheckBuffer
(
base
))
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
...
@@ -84,20 +85,17 @@ PyMemoryView_FromObject(PyObject *base)
...
@@ -84,20 +85,17 @@ PyMemoryView_FromObject(PyObject *base)
return
NULL
;
return
NULL
;
}
}
mview
=
(
PyMemoryViewObject
*
)
if
(
PyObject_GetBuffer
(
base
,
&
view
,
PyBUF_FULL_RO
)
<
0
)
PyObject_GC_New
(
PyMemoryViewObject
,
&
PyMemoryView_Type
);
if
(
mview
==
NULL
)
return
NULL
;
return
NULL
;
mview
->
base
=
NULL
;
mview
=
(
PyMemoryViewObject
*
)
PyMemoryView_FromBuffer
(
&
view
)
;
if
(
PyObject_GetBuffer
(
base
,
&
(
mview
->
view
),
PyBUF_FULL_RO
)
<
0
)
{
if
(
mview
==
NULL
)
{
Py
_DECREF
(
m
view
);
Py
Buffer_Release
(
&
view
);
return
NULL
;
return
NULL
;
}
}
mview
->
base
=
base
;
mview
->
base
=
base
;
Py_INCREF
(
base
);
Py_INCREF
(
base
);
_PyObject_GC_TRACK
(
mview
);
return
(
PyObject
*
)
mview
;
return
(
PyObject
*
)
mview
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment