Mercurial > octave
diff libinterp/octave-value/ov-fcn-handle.h @ 29185:76c94c998d7b stable
avoid memory leak with function handles (bug #59659)
* ov-fcn-handle.h, ov-fcn-handle.cc (octave_fcn_handle::m_rep):
Manage memory with std::shared_ptr. Update all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 14 Dec 2020 20:57:47 -0500 |
parents | eec0fe95576e |
children | 0a5b15007766 |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-fcn-handle.h Sun Dec 13 16:25:03 2020 +0100 +++ b/libinterp/octave-value/ov-fcn-handle.h Mon Dec 14 20:57:47 2020 -0500 @@ -30,6 +30,7 @@ #include <iosfwd> #include <list> +#include <memory> #include <string> #include "oct-map.h" @@ -325,11 +326,11 @@ private: - octave::base_fcn_handle *m_rep; + std::shared_ptr<octave::base_fcn_handle> m_rep; octave_fcn_handle (octave::base_fcn_handle *rep); - octave::base_fcn_handle * get_rep (void) const { return m_rep; } + octave::base_fcn_handle * get_rep (void) const { return m_rep.get (); } DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA };