[Libreoffice] [REVIEW] Fix for a crash during Multiple Operations
Kohei Yoshida
kyoshida at novell.com
Fri Jun 10 13:25:08 PDT 2011
I'd like to cherry-pick
http://cgit.freedesktop.org/libreoffice/calc/commit/?id=933a945c6c065d7a1897451bde57035d8597f580
to the -3-4 branch. There is no bug report associated with this, but
Tor found this while running demo code for UNO C# binding.
This is also one of the unfortunate crashers resulted from the
DECLARE_LIST removal. The original line as of 3.3 was
pDok->aTableOpList.Remove( pTableOp );
which removes the element from the container (if exists), but the object
itself is not destroyed. After the List was replaced with
boost::ptr_vector, the line changed to
pTableOp = pDok->aTableOpList.release( pDok->aTableOpList.end()
).release();
which almost nailed it, except that the end position iterator
pDok->aTableOpList.end()
doesn't point to any element so what that line does is undefined and
apparently causes a crash on Windows at least. I'm pretty sure that
back() was intended to be used instead of end() there. But even then,
the original code doesn't make the assumption that pTableOp was always
the last element of the list. So, the right thing to do here to
faithfully emulate the original code is to try to find pTableOp position
using std::find_if, followed by the release of that element from the
ptr_vector container using the iterator returned from the find_if call.
Kohei
P.S. BTW, Tor already gave me his sign-off on IRC and cherry-picked this
to the -3-4 branch while writing this mail, so no review is needed. ;-)
--
Kohei Yoshida, LibreOffice hacker, Calc
<kyoshida at novell.com>
More information about the LibreOffice
mailing list