Wrong indentation which leads to segfault in sc/source/ui/docshell/docfunc.cxx

julien2412 serval2412 at yahoo.fr
Tue Jan 1 07:40:13 PST 2013


Thank you John for your investigation about all this.

In fact, I was leafing through some cppcheck reports.
To simplify,  I pushed some slight fixes  in
sc/source/core/tool/autoform.cxx (see
http://cgit.freedesktop.org/libreoffice/core/commit/?id=2e1abe1c59b1121ffb5d46afe82ce985cb70c4db).
So now we've got this:
[sc/source/core/tool/autoform.cxx:1102] ->
[sc/source/core/tool/autoform.cxx:1105]: (performance) Variable 'bRet' is
reassigned a value before the old one has been used.

   1102         bRet = (rStream.GetError() == 0);
   1103        
//-----------------------------------------------------------
   1104         rStream << (sal_uInt16)(maData.size() - 1);
   1105         bRet = (rStream.GetError() == 0);
   1106         MapType::iterator it = maData.begin(), itEnd = maData.end();
   1107         for (++it; bRet && it != itEnd; ++it) // Skip the first
item.
   1108             bRet = it->second->Save(rStream, fileVersion);

So bRet value of 1102 isn't taken into account since there's another
assignation line 1105.
But just after, I noticed that at line 1107 "it" variable was increased
without checking it != itEnd
So I checked bugs concerning autoformats and ran into fdo#47466.
I gave a try to it by adding an "if (it != itEnd)" before line 1107 and
finally had the bt of my first message.

So I looked at the git history as you indicated and found about the missing
braces was due to a slight mistake during a cleaning.

I pushed a fix (see
http://cgit.freedesktop.org/libreoffice/core/commit/?id=f843850ee9994653673ef5591aae875d7fb22fed).

Now there are still the cppcheck report + the potential lacking of iterator
test before loop

Julien



--
View this message in context: http://nabble.documentfoundation.org/Wrong-indentation-which-leads-to-segfault-in-sc-source-ui-docshell-docfunc-cxx-tp4026726p4026790.html
Sent from the Dev mailing list archive at Nabble.com.


More information about the LibreOffice mailing list