[Libreoffice] [PATCH] Fix for dialog Manage Breakpoints crash

Eike Rathke erack at redhat.com
Mon Nov 28 15:25:09 PST 2011


Hi Niklas,

On Monday, 2011-11-28 12:27:16 +0100, Niklas Johansson wrote:

> In worst case it makes the program crash. This fix, stores
> the values. I'm not that experienced with C++ so could someone have
> a second look at this there might very well be a "cleaner" way of
> writing it.

Good find!

I think I would do it slightly different, the patch fixes the symptom
correctly by allocating new objects, but the underlying cause to me
seems that the original intention was to transfer the pointers (hence
the method's name) but that somehow got mangled with the transition from
old List to ::std::vector


> --- a/basctl/source/basicide/bastypes.cxx
> +++ b/basctl/source/basicide/bastypes.cxx
> @@ -288,7 +288,7 @@ void BreakPointList::transfer(BreakPointList & rList)
>  {
>      reset();
>      for (size_t i = 0; i < rList.size(); ++i)
> -        maBreakPoints.push_back( rList.at( i ) );
> +        maBreakPoints.push_back( new BreakPoint(*rList.at( i )) );
>      rList.reset();
>  }

Instead of creating copies I'd do

-      rList.reset();
+      rList.clear();

Please check if that fixes the problem.

  Eike

-- 
LibreOffice Calc developer. Number formatter stricken i18n transpositionizer.
GnuPG key 0x293C05FD : 997A 4C60 CE41 0149 0DB3  9E96 2F1A D073 293C 05FD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20111129/38476c12/attachment.pgp>


More information about the LibreOffice mailing list