Mercurial > octave
changeset 26980:4274f6962e6b
avoid using pointer to function after it is deleted (bug #55981)
* ov-usr-fcn.cc (octave_user_code::~octave_user_code):
Set pointer to function in corresponding scope to nullptr.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Mar 2019 14:06:44 +0000 |
parents | 86f0357cfb33 |
children | 12532d392693 |
files | libinterp/octave-value/ov-usr-fcn.cc |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-usr-fcn.cc Mon Mar 25 22:20:27 2019 -0700 +++ b/libinterp/octave-value/ov-usr-fcn.cc Tue Mar 26 14:06:44 2019 +0000 @@ -64,6 +64,12 @@ octave_user_code::~octave_user_code (void) { + // This function is no longer valid, so remove the pointer to it from + // the corresponding scope. + // FIXME: would it be better to use shared/weak pointers for this job + // instead of storing a bare pointer in the scope object? + m_scope.set_function (nullptr); + // FIXME: shouldn't this happen automatically when deleting cmd_list? if (cmd_list) cmd_list->remove_all_breakpoints (file_name);