]> git.lyx.org Git - features.git/commitdiff
Fix memory error detected by valgrind
authorGeorg Baum <baum@lyx.org>
Wed, 19 Nov 2014 19:42:04 +0000 (20:42 +0100)
committerGeorg Baum <baum@lyx.org>
Wed, 19 Nov 2014 19:42:04 +0000 (20:42 +0100)
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.

src/LaTeX.cpp
status.21x

index e4a23af117be4ede11a6b46d2b12e3bcec9d86a7..4d4b80b628037ef5b84e6831b0dd645afeefcb66 100644 (file)
@@ -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;
index af559f2f3b6d8babbf3128503a1f5fed44d20471..9ece51d7e9a69496602daf7a12936f846066c769 100644 (file)
@@ -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