From: Georg Baum Date: Wed, 19 Nov 2014 19:42:04 +0000 (+0100) Subject: Fix memory error detected by valgrind X-Git-Tag: 2.1.3~80 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e32147a1fefaaa7b0afe779d9f4fddb558e23d60;p=features.git Fix memory error detected by valgrind The assignment name = sub.str(1) reads from the first argument given to regex_match(), but previously this was a temporary object which was already out of scope. This did probably not matter much in practice, but invoked undefined behaviour, and as we all know this is allowed ton format your hard disk or kill to your cat, so better fix this. --- diff --git a/src/LaTeX.cpp b/src/LaTeX.cpp index e4a23af117..4d4b80b628 100644 --- a/src/LaTeX.cpp +++ b/src/LaTeX.cpp @@ -666,8 +666,8 @@ int LaTeX::scanLogFile(TeXErrors & terr) size_t len = j == string::npos ? token.substr(i + 1).length() : j - i - 1; - if (regex_match(token.substr(i + 1, len), - sub, child_file)) { + string const substr = token.substr(i + 1, len); + if (regex_match(substr, sub, child_file)) { string const name = sub.str(1); child.push(make_pair(name, pnest)); i += len; diff --git a/status.21x b/status.21x index af559f2f3b..9ece51d7e9 100644 --- a/status.21x +++ b/status.21x @@ -126,6 +126,8 @@ What's new - Fix possible memory corruption on copying to the clipboard +- Fix possible memory corruption during LaTeX log file parsing. + * DOCUMENTATION AND LOCALIZATION