# HG changeset patch # User John W. Eaton # Date 1553609204 0 # Node ID 4274f6962e6b14070784dce0c3ef172a166fda09 # Parent 86f0357cfb3313f17caf1664a694bf4473c3fef1 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. diff -r 86f0357cfb33 -r 4274f6962e6b libinterp/octave-value/ov-usr-fcn.cc --- 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);