From d334425314b2185b3c00fba4fac7b221d19059e8 Mon Sep 17 00:00:00 2001
From: Ian Bell <ian.bell@nist.gov>
Date: Thu, 3 Nov 2022 20:16:01 -0400
Subject: [PATCH] Fix memory problem with getter using temporary

---
 interface/pybind11_wrapper.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/interface/pybind11_wrapper.cpp b/interface/pybind11_wrapper.cpp
index 124367f..5b467c3 100644
--- a/interface/pybind11_wrapper.cpp
+++ b/interface/pybind11_wrapper.cpp
@@ -61,10 +61,9 @@ inline auto call_method_factory(py::module &m, const std::string& attribute) {
 }
 
 template<typename TYPE>
-TYPE& get_typed(py::object& o){
+const TYPE& get_typed(py::object& o){
     using namespace teqp::cppinterface;
-    auto model = o.cast<const AbstractModel *>()->get_model();
-    return std::get<TYPE>(model);
+    return std::get<TYPE>(o.cast<const AbstractModel *>()->get_model());
 }
 
 // You cannot know at runtime what is contained in the model so you must iterate
-- 
GitLab