diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-09-11 16:02:03 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-09-11 16:02:03 (GMT) |
commit | 568867a6f20c5944c0c0aba69603a4d8ff62dae6 (patch) | |
tree | 266fff4890746e7a8fd262bbdd3205bd61569853 | |
parent | e861598dcbe63bca1f71188a8ddbcbe2e100332f (diff) | |
download | cpython-568867a6f20c5944c0c0aba69603a4d8ff62dae6.zip cpython-568867a6f20c5944c0c0aba69603a4d8ff62dae6.tar.gz cpython-568867a6f20c5944c0c0aba69603a4d8ff62dae6.tar.bz2 |
check for NULL tp_as_mapping in PySequence_(Get/Set/Del)Slice #9834
-rw-r--r-- | Misc/NEWS | 7 | ||||
-rw-r--r-- | Objects/abstract.c | 6 |
2 files changed, 10 insertions, 3 deletions
@@ -108,6 +108,13 @@ Library guaranteed to exist in all Python implementations and the names of hash algorithms available in the current process. +C-API +----- + +- Issue #9834: Don't segfault in PySequence_GetSlice, PySequence_SetSlice, or + PySequence_DelSlice when the object doesn't have any mapping operations + defined. + Tools/Demos ----------- diff --git a/Objects/abstract.c b/Objects/abstract.c index 612271d..4eb33d3 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -1612,7 +1612,7 @@ PySequence_GetSlice(PyObject *s, Py_ssize_t i1, Py_ssize_t i2) if (!s) return null_error(); mp = s->ob_type->tp_as_mapping; - if (mp->mp_subscript) { + if (mp && mp->mp_subscript) { PyObject *res; PyObject *slice = _PySlice_FromIndices(i1, i2); if (!slice) @@ -1690,7 +1690,7 @@ PySequence_SetSlice(PyObject *s, Py_ssize_t i1, Py_ssize_t i2, PyObject *o) } mp = s->ob_type->tp_as_mapping; - if (mp->mp_ass_subscript) { + if (mp && mp->mp_ass_subscript) { int res; PyObject *slice = _PySlice_FromIndices(i1, i2); if (!slice) @@ -1715,7 +1715,7 @@ PySequence_DelSlice(PyObject *s, Py_ssize_t i1, Py_ssize_t i2) } mp = s->ob_type->tp_as_mapping; - if (mp->mp_ass_subscript) { + if (mp && mp->mp_ass_subscript) { int res; PyObject *slice = _PySlice_FromIndices(i1, i2); if (!slice) |