mirror of
https://github.com/RYDE-WORK/pybind11.git
synced 2026-02-06 23:56:59 +08:00
pybind11_getbuffer: useless safe nullptr check (#1664)
Alternative implementation for #1657: if we know that `obj` is never a `nullptr` [1], we should not `nullptr`-check it *after* already dereferencing it. [1] https://github.com/pybind/pybind11/pull/1657#issuecomment-452090058
This commit is contained in:
parent
f93cd0aa72
commit
1c627c9ec0
@ -469,7 +469,7 @@ extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int fla
|
|||||||
if (tinfo && tinfo->get_buffer)
|
if (tinfo && tinfo->get_buffer)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (view == nullptr || obj == nullptr || !tinfo || !tinfo->get_buffer) {
|
if (view == nullptr || !tinfo || !tinfo->get_buffer) {
|
||||||
if (view)
|
if (view)
|
||||||
view->obj = nullptr;
|
view->obj = nullptr;
|
||||||
PyErr_SetString(PyExc_BufferError, "pybind11_getbuffer(): Internal error");
|
PyErr_SetString(PyExc_BufferError, "pybind11_getbuffer(): Internal error");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user