Skip to content

Commit

Permalink
Move final assignment later
Browse files Browse the repository at this point in the history
  • Loading branch information
QuLogic committed Nov 8, 2024
1 parent 7fcf820 commit a3ff673
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/pybind11/detail/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,6 @@ extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int fla

// Fill in all the information, and then downgrade as requested by the caller, or raise an
// error if that's not possible.
view->obj = obj;
view->buf = info->ptr;
view->itemsize = info->itemsize;
view->len = view->itemsize;
Expand Down Expand Up @@ -659,7 +658,10 @@ extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int fla
}
}

// Set these after all checks so they don't leak out into the caller, and can be automatically
// cleaned up on error.
view->internal = info.release();
view->obj = obj;
Py_INCREF(view->obj);
return 0;
}
Expand Down

0 comments on commit a3ff673

Please sign in to comment.