About coverity 705746 (pormulti.cxx from sw module)

Noel Grandin noel at peralex.com
Thu Mar 14 23:39:23 PDT 2013


On 2013-03-14 21:20, julien2412 wrote:
> Hello,
>
> Scan coverity detected this:
> 27. overwrite_var: Overwriting "pMarg" in "pMarg = new SwMarginPortion(0)"
> leaks the storage that "pMarg" points to
>
> (http://opengrok.libreoffice.org/xref/core/sw/source/core/text/pormulti.cxx#738)
>      738     if( nLeft || nRight )
>      739     {
>      740         if( !pCurr->GetPortion() )
>      741             pCurr->SetPortion( new SwTxtPortion( *pCurr ) );
>      742         SwMarginPortion *pMarg = new SwMarginPortion( 0 );
>      743         if( nLeft )
>      744         {
>      745             pMarg->AddPrtWidth( nLeft );
>      746             pMarg->SetPortion( pCurr->GetPortion() );
>      747             pCurr->SetPortion( pMarg );
>      748         }
>      749         if( nRight )
>      750         {
>      751             pMarg = new SwMarginPortion( 0 );
>      752             pMarg->AddPrtWidth( nRight );
>      753             pCurr->FindLastPortion()->Append( pMarg );
>      754         }
>      755     }
>
> I don't understand the line 751, shouldn't it simply removed or does it lack
> something too?
>

I would guess that someone meant to move line 742 inside the first "if" 
statement, but only did half the job.

Disclaimer: http://www.peralex.com/disclaimer.html




More information about the LibreOffice mailing list