]> git.lyx.org Git - features.git/commit
Fix math macro crash (bug 9418)
authorGeorg Baum <baum@lyx.org>
Thu, 2 Apr 2015 19:35:05 +0000 (21:35 +0200)
committerGeorg Baum <baum@lyx.org>
Thu, 2 Apr 2015 19:35:05 +0000 (21:35 +0200)
commit1b5875043dafd5b900eb14676bdce0eee235b2ae
tree2fe43aadb780fef7e838f85a66efd5b82ae01e4f
parent948ed1ffd50923f3e63204c65a08cb308ebc4b63
Fix math macro crash (bug 9418)

In the test case the crash occured in mathml export of the temporary buffer,
because the macro was updated, and because one of the used other macros was
not copied, the macro argument was detached. However, the underlying problem
of the crash was a broken ArgumentProxy::mathMacro_ reference which became
invalid each time the ownng MathMacro was copied. In the bug test case the
copying happened due to resizing a std::vector, but any other copy would have
created the same problem. The crash did not always happen, because sometimes
the old freed memory was not immediately reused, so the invalid reference did
still point to usable data.

The fix is easy: Convert ArgumentProxy::mathMacro_ to a pointer and update it
always after creating a copy of the owner. The pimpl of MathMacro from the
previous commit helps here to distinguish between the data that can be
automatically copied (in MathMacro::Private) and the cleanup that needs to be
done manually (in MathMacro). This way, the manual copy constructor and
assigment operator of MathMacro does not need to be touched if a new member is
added.
src/mathed/MathMacro.cpp