From 33a92d56aeaadfe8dad246ae17b091e14b220e82 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Thu, 21 Jul 2016 08:55:44 +0200 Subject: [PATCH] [bugfix] Fix crash in basic::subs(). A regression in 1.7.0 was introduced with 1b8bcb06 in function basic::subs_one_level(): implicitly casting *this to an ex first for finding *this in m and later in the function's return statement caused a crash in the second cast because *this was deleted in the first one. After all, *this was dynamically allocated in basic::subs(). This bug was reported and hunted down by Mario Prausa. --- ginac/basic.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 1a3438e7..59e7dbd9 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -585,10 +585,11 @@ bool basic::match(const ex & pattern, exmap& repl_lst) const ex basic::subs_one_level(const exmap & m, unsigned options) const { if (options & subs_options::no_pattern) { - auto it = m.find(*this); + ex thisex = *this; // NB: *this may be deleted here. + auto it = m.find(thisex); if (it != m.end()) return it->second; - return *this; + return thisex; } else { for (auto & it : m) { exmap repl_lst; -- 2.44.0