[Libreoffice-commits] core.git: 6 commits - formula/source lotuswordpro/source sw/source vcl/inc vcl/unx

Caolán McNamara caolanm at redhat.com
Mon Oct 14 13:10:09 PDT 2013


 formula/source/ui/dlg/parawin.cxx      |    8 +--
 lotuswordpro/source/filter/lwpfrib.cxx |   12 ++++-
 sw/source/core/fields/chpfld.cxx       |   11 ++++-
 vcl/inc/salwtype.hxx                   |    9 ++++
 vcl/unx/generic/app/i18n_cb.cxx        |   67 ++++++++++++++++-----------------
 vcl/unx/generic/window/salframe.cxx    |    2 
 6 files changed, 66 insertions(+), 43 deletions(-)

New commits:
commit 20528cb2702d7044734ec1f4a9af40804bce1c0e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Oct 14 21:08:40 2013 +0100

    CID#736176 aArgInput is only 4 items, what's with the loop over 5 elements
    
    Change-Id: I16983832e5d12ae55a3db448bcef2550b000d496

diff --git a/formula/source/ui/dlg/parawin.cxx b/formula/source/ui/dlg/parawin.cxx
index 1b0a6db..c209c37 100644
--- a/formula/source/ui/dlg/parawin.cxx
+++ b/formula/source/ui/dlg/parawin.cxx
@@ -513,7 +513,7 @@ IMPL_LINK( ParaWin, GetFxHdl, ArgInput*, pPtr )
 {
     sal_uInt16 nOffset = GetSliderPos();
     nEdFocus=NOT_FOUND;
-    for ( sal_uInt16 nPos=0; nPos<5;nPos++)
+    for (sal_uInt16 nPos=0; nPos < SAL_N_ELEMENTS(aArgInput); ++nPos)
     {
         if(pPtr == &aArgInput[nPos])
         {
@@ -535,7 +535,7 @@ IMPL_LINK( ParaWin, GetFxFocusHdl, ArgInput*, pPtr )
 {
     sal_uInt16 nOffset = GetSliderPos();
     nEdFocus=NOT_FOUND;
-    for ( sal_uInt16 nPos=0; nPos<5;nPos++)
+    for (sal_uInt16 nPos=0; nPos < SAL_N_ELEMENTS(aArgInput); ++nPos)
     {
         if(pPtr == &aArgInput[nPos])
         {
@@ -559,7 +559,7 @@ IMPL_LINK( ParaWin, GetEdFocusHdl, ArgInput*, pPtr )
 {
     sal_uInt16 nOffset = GetSliderPos();
     nEdFocus=NOT_FOUND;
-    for ( sal_uInt16 nPos=0; nPos<5;nPos++)
+    for (sal_uInt16 nPos=0; nPos < SAL_N_ELEMENTS(aArgInput); ++nPos)
     {
         if(pPtr == &aArgInput[nPos])
         {
@@ -591,7 +591,7 @@ IMPL_LINK( ParaWin, ModifyHdl, ArgInput*, pPtr )
 {
     sal_uInt16 nOffset = GetSliderPos();
     nEdFocus=NOT_FOUND;
-    for ( sal_uInt16 nPos=0; nPos<5;nPos++)
+    for (sal_uInt16 nPos=0; nPos < SAL_N_ELEMENTS(aArgInput); ++nPos)
     {
         if(pPtr == &aArgInput[nPos])
         {
commit eb0d268cdb71513b8ca36ce6582a06e34190c54d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Oct 14 20:59:34 2013 +0100

    CID#736192 out of bounds
    
    Change-Id: I7ab1baa96e004122bd03d7b057effaf6b1ca7fe2

diff --git a/sw/source/core/fields/chpfld.cxx b/sw/source/core/fields/chpfld.cxx
index ddda6c4..7c1eb52 100644
--- a/sw/source/core/fields/chpfld.cxx
+++ b/sw/source/core/fields/chpfld.cxx
@@ -135,7 +135,16 @@ void SwChapterField::ChangeExpansion(const SwTxtNode &rTxtNd, sal_Bool bSrchNum)
         if (rTxtNd.IsCountedInList() && pRule)
         {
             sNumber = rTxtNd.GetNumString(false);
-            const SwNumFmt& rNFmt = pRule->Get(static_cast<unsigned short>(rTxtNd.GetActualListLevel()));
+
+            int nListLevel = rTxtNd.GetActualListLevel();
+
+            if (nListLevel < 0)
+                nListLevel = 0;
+
+            if (nListLevel >= MAXLEVEL)
+                nListLevel = MAXLEVEL - 1;
+
+            const SwNumFmt& rNFmt = pRule->Get(static_cast<unsigned short>(nListLevel));
             sPost = rNFmt.GetSuffix();
             sPre = rNFmt.GetPrefix();
         }
commit b8d18c1b27e97e14a83338c6b18239637b744834
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Oct 14 20:51:54 2013 +0100

    CID#738972 use after free
    
    Change-Id: I3c1329a55b53365945406c515ff4e8e72792dcb6

diff --git a/lotuswordpro/source/filter/lwpfrib.cxx b/lotuswordpro/source/filter/lwpfrib.cxx
index 9ef736d..ca91ef9 100644
--- a/lotuswordpro/source/filter/lwpfrib.cxx
+++ b/lotuswordpro/source/filter/lwpfrib.cxx
@@ -255,8 +255,11 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
             pStyle->SetStyleName(A2OUSTR(""));
             pFont = pFoundry->GetFontManger()->CreateOverrideFont(pCharStyle->GetFinalFontID(),m_pModifiers->FontID);
             pStyle->SetFont(pFont);
-            m_StyleName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
-            }
+            IXFStyle *pNewStyle = pXFStyleManager->AddStyle(pStyle);
+            m_StyleName = pNewStyle->GetStyleName();
+            if (pNewStyle != pStyle)
+                pStyle = NULL;
+        }
         else
             m_StyleName =  pNamedStyle->GetStyleName();
     }
@@ -267,7 +270,10 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
             pStyle = new XFTextStyle();
             pFont = pFoundry->GetFontManger()->CreateFont(m_pModifiers->FontID);
             pStyle->SetFont(pFont);
-            m_StyleName = pXFStyleManager->AddStyle(pStyle)->GetStyleName();
+            IXFStyle *pNewStyle = pXFStyleManager->AddStyle(pStyle);
+            m_StyleName = pNewStyle->GetStyleName();
+            if (pNewStyle != pStyle)
+                pStyle = NULL;
         }
     }
 
commit 5d4c63c815c38106d1d80e817e96c5cb0fbaaccf
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Oct 14 20:43:02 2013 +0100

    CID#707595 uninitialized values
    
    Change-Id: Ic41348b7ebce95325c8449c21b6f303ca54c2417

diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index d723f89..2859993 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -2666,7 +2666,7 @@ void X11SalFrame::SimulateKeyPress( sal_uInt16 nKeyCode )
 
 long X11SalFrame::HandleMouseEvent( XEvent *pEvent )
 {
-    SalMouseEvent       aMouseEvt;
+    SalMouseEvent       aMouseEvt = {0, 0, 0, 0, 0};
     sal_uInt16              nEvent = 0;
     bool                bClosePopups = false;
 
commit 3e7bf110643b2672c582c706f41527928d38a669
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Oct 14 20:40:30 2013 +0100

    CID#707583 uninitialized variables
    
    Change-Id: I2e494843226b4dcb72eadfabd55f6e6de42ddfc6

diff --git a/vcl/inc/salwtype.hxx b/vcl/inc/salwtype.hxx
index 1ae6087..544c7ad 100644
--- a/vcl/inc/salwtype.hxx
+++ b/vcl/inc/salwtype.hxx
@@ -191,6 +191,15 @@ struct SalExtTextInputPosEvent
     long            mnHeight;       // Cursor-Height in Pixel
     long            mnExtWidth;     // Width of the PreEdit area
     bool            mbVertical;     // true if in vertical mode
+    SalExtTextInputPosEvent()
+        : mnX(0)
+        , mnY(0)
+        , mnWidth(0)
+        , mnHeight(0)
+        , mnExtWidth(0)
+        , mbVertical(false)
+    {
+    }
 };
 
 // INPUTCONTEXTCHANGE
commit 6f30b8705222262d707b6f395866e76bfb521c14
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Oct 14 20:38:32 2013 +0100

    fix mangled indent
    
    Change-Id: Iefef3ac1e56444e387916dd1eae65007152c831e

diff --git a/vcl/unx/generic/app/i18n_cb.cxx b/vcl/unx/generic/app/i18n_cb.cxx
index 04b41fb..6c34568 100644
--- a/vcl/unx/generic/app/i18n_cb.cxx
+++ b/vcl/unx/generic/app/i18n_cb.cxx
@@ -321,7 +321,7 @@ void
 PreeditDrawCallback(XIC ic, XPointer client_data,
             XIMPreeditDrawCallbackStruct *call_data)
 {
-      preedit_data_t* pPreeditData = (preedit_data_t*)client_data;
+    preedit_data_t* pPreeditData = (preedit_data_t*)client_data;
 
     // if there's nothing to change then change nothing
     if ( ( (call_data->text == NULL) && (call_data->chg_length == 0) )
@@ -341,11 +341,11 @@ PreeditDrawCallback(XIC ic, XPointer client_data,
       // chg_first and chg_length are guaranteed to be nonnegative
 
       // handle text deletion
-      if (call_data->text == NULL)
+    if (call_data->text == NULL)
     {
         Preedit_DeleteText(&(pPreeditData->aText),
                call_data->chg_first, call_data->chg_length );
-      }
+    }
     else
     {
         // handle text insertion
@@ -355,42 +355,41 @@ PreeditDrawCallback(XIC ic, XPointer client_data,
               Preedit_InsertText(&(pPreeditData->aText), call_data->text,
                      call_data->chg_first);
         }
-        else
-          // handle text replacement by deletion and insertion of text,
-          // not smart, just good enough
-          if (   (call_data->chg_length != 0)
+        else if (   (call_data->chg_length != 0)
               && (call_data->text->string.wide_char != NULL))
         {
+            // handle text replacement by deletion and insertion of text,
+            // not smart, just good enough
+
             Preedit_DeleteText(&(pPreeditData->aText),
                        call_data->chg_first, call_data->chg_length);
             Preedit_InsertText(&(pPreeditData->aText), call_data->text,
                        call_data->chg_first);
           }
-        else
-        // not really a text update, only attributes are concerned
-        if (   (call_data->chg_length != 0)
+        else if (   (call_data->chg_length != 0)
             && (call_data->text->string.wide_char == NULL))
         {
+            // not really a text update, only attributes are concerned
               Preedit_UpdateAttributes(&(pPreeditData->aText),
                    call_data->text->feedback,
                    call_data->chg_first, call_data->chg_length);
         }
-      }
+    }
 
-      //
-      // build the SalExtTextInputEvent and send it up
-      //
-      pPreeditData->aInputEv.mnTime = 0;
-      pPreeditData->aInputEv.mpTextAttr = Preedit_FeedbackToSAL(
-            pPreeditData->aText.pCharStyle, pPreeditData->aText.nLength, pPreeditData->aInputFlags);
-      pPreeditData->aInputEv.mnCursorPos = call_data->caret;
-      pPreeditData->aInputEv.maText = OUString(pPreeditData->aText.pUnicodeBuffer,
+    //
+    // build the SalExtTextInputEvent and send it up
+    //
+    pPreeditData->aInputEv.mnTime = 0;
+    pPreeditData->aInputEv.mpTextAttr = Preedit_FeedbackToSAL(
+        pPreeditData->aText.pCharStyle, pPreeditData->aText.nLength, pPreeditData->aInputFlags);
+    pPreeditData->aInputEv.mnCursorPos = call_data->caret;
+    pPreeditData->aInputEv.maText = OUString(pPreeditData->aText.pUnicodeBuffer,
                                 pPreeditData->aText.nLength);
     pPreeditData->aInputEv.mnCursorFlags    = 0; // default: make cursor visible
-      pPreeditData->aInputEv.mnDeltaStart = 0; // call_data->chg_first;
-      pPreeditData->aInputEv.mbOnlyCursor = False;
+    pPreeditData->aInputEv.mnDeltaStart = 0; // call_data->chg_first;
+    pPreeditData->aInputEv.mbOnlyCursor = False;
 
-      if ( pPreeditData->eState == ePreeditStatusActive && pPreeditData->pFrame )
+    if ( pPreeditData->eState == ePreeditStatusActive && pPreeditData->pFrame )
         pPreeditData->pFrame->CallCallback(SALEVENT_EXTTEXTINPUT, (void*)&pPreeditData->aInputEv);
     if (pPreeditData->aText.nLength == 0 && pPreeditData->pFrame )
         pPreeditData->pFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, (void*)NULL );
@@ -404,23 +403,23 @@ PreeditDrawCallback(XIC ic, XPointer client_data,
 void
 GetPreeditSpotLocation(XIC ic, XPointer client_data)
 {
-      //
-      // Send SalEventExtTextInputPos event to get spotlocation
-      //
-      SalExtTextInputPosEvent mPosEvent;
-      preedit_data_t* pPreeditData = (preedit_data_t*)client_data;
+    //
+    // Send SalEventExtTextInputPos event to get spotlocation
+    //
+    SalExtTextInputPosEvent mPosEvent;
+    preedit_data_t* pPreeditData = (preedit_data_t*)client_data;
 
     if( pPreeditData->pFrame )
         pPreeditData->pFrame->CallCallback(SALEVENT_EXTTEXTINPUTPOS, (void*)&mPosEvent);
 
-      XPoint point;
-      point.x = mPosEvent.mnX + mPosEvent.mnWidth;
-      point.y = mPosEvent.mnY + mPosEvent.mnHeight;
+    XPoint point;
+    point.x = mPosEvent.mnX + mPosEvent.mnWidth;
+    point.y = mPosEvent.mnY + mPosEvent.mnHeight;
 
-      XVaNestedList preedit_attr;
-      preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &point, NULL);
-      XSetICValues(ic, XNPreeditAttributes, preedit_attr, NULL);
-      XFree(preedit_attr);
+    XVaNestedList preedit_attr;
+    preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &point, NULL);
+    XSetICValues(ic, XNPreeditAttributes, preedit_attr, NULL);
+    XFree(preedit_attr);
 
     return;
 }


More information about the Libreoffice-commits mailing list