From 02ffbf16fe7cfb78cdfaa5b6e1ac3385355823b2 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Fri, 14 Apr 2017 13:57:49 -0400 Subject: [PATCH] Fix PyBuffer_Release leak 5f38386293f989db87545ce8a619e55085068060 accidentally dropped setting buffer_info.view, resulting in the buffer never being released (because view was always nullptr). --- include/pybind11/buffer_info.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/pybind11/buffer_info.h b/include/pybind11/buffer_info.h index 54451ee3d..e4029b983 100644 --- a/include/pybind11/buffer_info.h +++ b/include/pybind11/buffer_info.h @@ -38,10 +38,11 @@ struct buffer_info { buffer_info(void *ptr, size_t itemsize, const std::string &format, size_t size) : buffer_info(ptr, itemsize, format, 1, size, itemsize) { } - explicit buffer_info(Py_buffer *view, bool ownview_in = true) + explicit buffer_info(Py_buffer *view, bool ownview = true) : buffer_info(view->buf, (size_t) view->itemsize, view->format, (size_t) view->ndim, {view->shape, view->shape + view->ndim}, {view->strides, view->strides + view->ndim}) { - ownview = ownview_in; + this->view = view; + this->ownview = ownview; } buffer_info(const buffer_info &) = delete;