This patch fixes crash while processing MathML objects that contain invalid <mmultiscripts> elements.<br><br>MathML object "Object 1/content.xml" from "Formula-crash.odp" file (attached to bug report <a href="https://bugs.freedesktop.org/show_bug.cgi?id=39898" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=39898</a> ) contains the following element:<br>
<br><span style="font-family:courier new,monospace"><mmultiscripts></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> <mtext/></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> <mprescripts/></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> <none/></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"></mmultiscripts></span><br><br>This <mmultiscripts> element is invalid since it contains odd number of elements after <mprescripts/> (see <a href="http://www.w3.org/TR/MathML/chapter3.html#presm.mmultiscripts" target="_blank">http://www.w3.org/TR/MathML/chapter3.html#presm.mmultiscripts</a> ) and LibreOffice crashes on it.<br>
<br>I found inconsistency between SmXMLMultiScriptsContext_Impl::EndElement and SmXMLMultiScriptsContext_Impl::MiddleElement (file starmath/source/mathmlimport.cxx). <span lang="en"><span>MiddleElement used for processing postscripts and EndElement used for processing prescripts. The contents of these methods are</span> <span>almost</span> <span>identical, but </span></span>in MiddleElement we can see:<br>
<br><span style="font-family:courier new,monospace">if (pScriptNode->GetToken().aText.Len())</span><span style="font-family:courier new,monospace"></span><br><br>and in EndElement:<br><br><span style="font-family:courier new,monospace">if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||</span><br style="font-family:courier new,monospace">
<div style="margin-left:40px"><span style="font-family:courier new,monospace">(pScriptNode->GetToken().aText.Len())))</span><span style="font-family:courier new,monospace"><br></span></div><span style="font-family:courier new,monospace"></span><br>
<span style="font-family:courier new,monospace"></span>In method MiddleElement variable pScriptNode becomes NULL if number of elements is odd. So, I merged
content of methods MiddleElement and EndElement into method
ProcessSubSupPairs using second variant of the condition.