sw/source/filter/ww8/ww8par6.cxx |  122 ++++++++++++++++++++-------------------
 vcl/source/gdi/bitmap.cxx        |    2 
 2 files changed, 66 insertions(+), 58 deletions(-)

New commits:
commit b4d6590ff572eb6c9f3455c718cc89336cf15c54
Author: Caolán McNamara <caol...@redhat.com>
Date:   Thu Apr 6 16:54:23 2017 +0100

    ofz: treat more short properties as run ends
    
    Change-Id: I010317f9e68e377a33c04c3dbac0dd075475dbe8

diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 538486ea91c4..9f4cbac539be 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2683,7 +2683,7 @@ const SfxPoolItem* SwWW8ImplReader::GetFormatAttr( 
sal_uInt16 nWhich )
 // parameters according to the table in WWScan.cxx.
 void SwWW8ImplReader::Read_Special(sal_uInt16, const sal_uInt8* pData, short 
nLen)
 {
-    if( nLen < 0 )
+    if (nLen < 1)
     {
         m_bSpec = false;
         return;
@@ -2694,7 +2694,7 @@ void SwWW8ImplReader::Read_Special(sal_uInt16, const 
sal_uInt8* pData, short nLe
 // Read_Obj is used for fObj and for fOle2 !
 void SwWW8ImplReader::Read_Obj(sal_uInt16 , const sal_uInt8* pData, short nLen)
 {
-    if( nLen < 0 )
+    if (nLen < 1)
         m_bObj = false;
     else
     {
@@ -2717,7 +2717,7 @@ void SwWW8ImplReader::Read_Obj(sal_uInt16 , const 
sal_uInt8* pData, short nLen)
 
 void SwWW8ImplReader::Read_PicLoc(sal_uInt16 , const sal_uInt8* pData, short 
nLen )
 {
-    if( nLen < 0 )
+    if (nLen < 4)
     {
         m_nPicLocFc = 0;
         m_bSpec = false;  // Is this always correct?
@@ -2746,7 +2746,7 @@ void SwWW8ImplReader::Read_POutLvl(sal_uInt16, const 
sal_uInt8* pData, short nLe
         if (pSI != nullptr)
         {
             pSI->mnWW8OutlineLevel =
-                    static_cast< sal_uInt8 >( ( pData ? *pData : 0 ) );
+                    static_cast< sal_uInt8 >( ( (pData && nLen >= 1) ? *pData 
: 0 ) );
             NewAttr( SfxUInt16Item( RES_PARATR_OUTLINELEVEL, 
SwWW8StyInf::WW8OutlineLevelToOutlinelevel( pSI->mnWW8OutlineLevel ) ) );
         }
     }
@@ -2754,7 +2754,7 @@ void SwWW8ImplReader::Read_POutLvl(sal_uInt16, const 
sal_uInt8* pData, short nLe
     {
         const sal_uInt8 nOutlineLevel
             = SwWW8StyInf::WW8OutlineLevelToOutlinelevel(
-                static_cast<sal_uInt8>((pData ? *pData : 0)));
+                static_cast<sal_uInt8>(((pData && nLen >= 1) ? *pData : 0)));
         NewAttr(SfxUInt16Item(RES_PARATR_OUTLINELEVEL, nOutlineLevel));
     }
 }
@@ -2763,7 +2763,7 @@ void SwWW8ImplReader::Read_Symbol(sal_uInt16, const 
sal_uInt8* pData, short nLen
 {
     if( !m_bIgnoreText )
     {
-        if( nLen < 0 )
+        if (nLen < m_bVer67 ? 3 : 4)
         {
             //otherwise disable after we print the char
             if (m_pPlcxMan && m_pPlcxMan->GetDoingDrawTextBox())
@@ -2848,7 +2848,7 @@ void SwWW8ImplReader::Read_BoldUsw( sal_uInt16 nId, const 
sal_uInt8* pData, shor
 
     sal_uInt16 nMask = 1 << nI;
 
-    if (nLen < 0)
+    if (nLen < 1)
     {
         if (nI < 2)
         {
@@ -2914,7 +2914,7 @@ void SwWW8ImplReader::Read_BoldUsw( sal_uInt16 nId, const 
sal_uInt8* pData, shor
 
 void SwWW8ImplReader::Read_Bidi(sal_uInt16, const sal_uInt8* pData, short nLen)
 {
-    if( nLen < 0 )  //Property end
+    if (nLen < 1)  //Property end
     {
         m_bBidi = false;
         m_pCtrlStck->SetAttr(*m_pPaM->GetPoint(),RES_CHRATR_BIDIRTL);
@@ -3028,7 +3028,7 @@ void SwWW8ImplReader::Read_BoldBiDiUsw(sal_uInt16 nId, 
const sal_uInt8* pData,
 
     sal_uInt16 nMask = 1 << nI;
 
-    if( nLen < 0 )
+    if (nLen < 1)
     {
         m_pCtrlStck->SetAttr(*m_pPaM->GetPoint(),nEndIds[nI]);
         m_pCtrlStck->SetToggleBiDiAttr(nI, false);
@@ -3196,7 +3196,8 @@ void SwWW8ImplReader::ChkToggleBiDiAttr_( sal_uInt16 
nOldStyle81Mask,
 
 void SwWW8ImplReader::Read_SubSuper( sal_uInt16, const sal_uInt8* pData, short 
nLen )
 {
-    if( nLen < 0 ){
+    if (nLen < 1)
+    {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_ESCAPEMENT );
         return;
     }
@@ -3288,7 +3289,7 @@ bool SwWW8ImplReader::ConvertSubToGraphicPlacement()
 
 void SwWW8ImplReader::Read_SubSuperProp( sal_uInt16, const sal_uInt8* pData, 
short nLen )
 {
-    if( nLen < 0 )
+    if (nLen < ww::eWW2 ? 1 : 2)
     {
         if (!ConvertSubToGraphicPlacement())
             m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_ESCAPEMENT );
@@ -3321,7 +3322,7 @@ void SwWW8ImplReader::Read_Underline( sal_uInt16, const 
sal_uInt8* pData, short
 {
     FontLineStyle eUnderline = LINESTYLE_NONE;
     bool bWordLine = false;
-    if( pData )
+    if (pData && nLen)
     {
         // Parameter:  0 = none,    1 = single,  2 = by Word,
                     // 3 = double,  4 = dotted,  5 = hidden
@@ -3351,7 +3352,7 @@ void SwWW8ImplReader::Read_Underline( sal_uInt16, const 
sal_uInt8* pData, short
     }
 
     // if necessary, mix up stack and exit!
-    if( nLen < 0 )
+    if (nLen < 1)
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_UNDERLINE );
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_WORDLINEMODE );
@@ -3375,7 +3376,7 @@ NoBracket   78 CA 06 -  02 00 00 02 34 52
 void SwWW8ImplReader::Read_DoubleLine_Rotate( sal_uInt16, const sal_uInt8* 
pData,
     short nLen )
 {
-    if( nLen < 0 ) // close the tag
+    if (nLen < 0) // close the tag
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_TWO_LINES );
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_ROTATE );
@@ -3414,7 +3415,7 @@ void SwWW8ImplReader::Read_TextColor( sal_uInt16, const 
sal_uInt8* pData, short
     if (!m_bVer67 && m_pPlcxMan && 
m_pPlcxMan->GetChpPLCF()->HasSprm(NS_sprm::sprmCCv))
         return;
 
-    if( nLen < 0 )
+    if (nLen < 1)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_COLOR );
     else
     {
@@ -3431,7 +3432,7 @@ void SwWW8ImplReader::Read_TextColor( sal_uInt16, const 
sal_uInt8* pData, short
 
 void SwWW8ImplReader::Read_TextForeColor(sal_uInt16, const sal_uInt8* pData, 
short nLen)
 {
-    if( nLen < 0 )
+    if (nLen < 4)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_COLOR );
     else
     {
@@ -3444,7 +3445,7 @@ void SwWW8ImplReader::Read_TextForeColor(sal_uInt16, 
const sal_uInt8* pData, sho
 
 void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, const sal_uInt8* pData, 
short nLen)
 {
-    if( nLen < 0 )
+    if (nLen < 0)
     {
         //because the UnderlineColor is not a standalone attribute in SW, it 
belongs to the underline attribute.
         //And, the .doc file stores attributes separately, this attribute ends 
here, the "underline"
@@ -3461,7 +3462,8 @@ void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, 
const sal_uInt8* pData, sh
                 const SwAttrSet& aSet = m_pAktColl->GetAttrSet();
                 SvxUnderlineItem *pUnderline
                     = static_cast<SvxUnderlineItem *>(aSet.Get( 
RES_CHRATR_UNDERLINE, false ).Clone());
-                if(pUnderline){
+                if (pUnderline && nLen >= 4)
+                {
                     pUnderline->SetColor( Color( 
msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)) ) );
                     m_pAktColl->SetFormatAttr( *pUnderline );
                     delete pUnderline;
@@ -3474,7 +3476,8 @@ void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, 
const sal_uInt8* pData, sh
             {
                 SvxUnderlineItem *pUnderline
                     = static_cast<SvxUnderlineItem *>(m_pAktItemSet->Get( 
RES_CHRATR_UNDERLINE, false ) .Clone());
-                if(pUnderline){
+                if (pUnderline && nLen >= 4)
+                {
                     pUnderline->SetColor( Color( 
msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)) ) );
                     m_pAktItemSet->Put( *pUnderline );
                     delete pUnderline;
@@ -3484,7 +3487,7 @@ void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, 
const sal_uInt8* pData, sh
         else
         {
             SvxUnderlineItem* pUnderlineAttr = 
const_cast<SvxUnderlineItem*>(static_cast<const 
SvxUnderlineItem*>(m_pCtrlStck->GetOpenStackAttr( *m_pPaM->GetPoint(), 
RES_CHRATR_UNDERLINE )));
-            if( pUnderlineAttr != nullptr )
+            if (pUnderlineAttr && nLen >= 4)
                 pUnderlineAttr->SetColor( Color( 
msfilter::util::BGRToRGB(SVBT32ToUInt32( pData ))));
         }
     }
@@ -3707,7 +3710,7 @@ void SwWW8ImplReader::Read_FontCode( sal_uInt16 nId, 
const sal_uInt8* pData, sho
 
         ww::WordVersion eVersion = m_pWwFib->GetFIBVersion();
 
-        if( nLen < 0 ) // end of attribute
+        if (nLen < 2) // end of attribute
         {
             if (eVersion <= ww::eWW6)
             {
@@ -3749,7 +3752,7 @@ void SwWW8ImplReader::Read_FontSize( sal_uInt16 nId, 
const sal_uInt8* pData, sho
 
     ww::WordVersion eVersion = m_pWwFib->GetFIBVersion();
 
-    if( nLen < 0 )          // end of attribute
+    if (nLen < (eVersion <= ww::eWW2 ? 1 : 2))          // end of attribute
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), nId  );
         if (eVersion <= ww::eWW6) // reset additionally the CTL size
@@ -3792,14 +3795,14 @@ void SwWW8ImplReader::Read_FontSize( sal_uInt16 nId, 
const sal_uInt8* pData, sho
 
 void SwWW8ImplReader::Read_CharSet(sal_uInt16 , const sal_uInt8* pData, short 
nLen)
 {
-    if( nLen < 0 )
+    if (nLen < 1)
     {                   // end of attribute
         m_eHardCharSet = RTL_TEXTENCODING_DONTKNOW;
         return;
     }
     sal_uInt8 nfChsDiff = *pData;
 
-    if( nfChsDiff )
+    if (nfChsDiff && nLen >= 2)
         m_eHardCharSet = rtl_getTextEncodingFromWindowsCharset( *(pData + 1) );
     else
         m_eHardCharSet = RTL_TEXTENCODING_DONTKNOW;
@@ -3841,7 +3844,8 @@ void SwWW8ImplReader::Read_Language( sal_uInt16 nId, 
const sal_uInt8* pData, sho
 */
 void SwWW8ImplReader::Read_CColl( sal_uInt16, const sal_uInt8* pData, short 
nLen )
 {
-    if( nLen < 0 ){                 // end of attribute
+    if (nLen < 2)    // end of attribute
+    {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_TXTATR_CHARFMT );
         m_nCharFormat = -1;
         return;
@@ -3870,7 +3874,8 @@ void SwWW8ImplReader::Read_CColl( sal_uInt16, const 
sal_uInt8* pData, short nLen
 */
 void SwWW8ImplReader::Read_Kern( sal_uInt16, const sal_uInt8* pData, short 
nLen )
 {
-    if( nLen < 0 ){                 // end of attribute
+    if (nLen < 2)  // end of attribute
+    {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_KERNING );
         return;
     }
@@ -3880,7 +3885,7 @@ void SwWW8ImplReader::Read_Kern( sal_uInt16, const 
sal_uInt8* pData, short nLen
 
 void SwWW8ImplReader::Read_FontKern( sal_uInt16, const sal_uInt8* , short nLen 
)
 {
-    if( nLen < 0 ) // end of attribute
+    if (nLen < 0) // end of attribute
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_AUTOKERN );
     else
         NewAttr(SvxAutoKernItem(true, RES_CHRATR_AUTOKERN));
@@ -3892,7 +3897,7 @@ void SwWW8ImplReader::Read_CharShadow(  sal_uInt16, const 
sal_uInt8* pData, shor
     if (!m_bVer67 && m_pPlcxMan && m_pPlcxMan->GetChpPLCF()->HasSprm(0xCA71))
         return;
 
-    if( nLen <= 0 )
+    if (nLen < 2)
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_BACKGROUND );
     }
@@ -3914,7 +3919,7 @@ void SwWW8ImplReader::Read_CharShadow(  sal_uInt16, const 
sal_uInt8* pData, shor
 
 void SwWW8ImplReader::Read_TextBackColor(sal_uInt16, const sal_uInt8* pData, 
short nLen )
 {
-    if( nLen <= 0 )
+    if (nLen <= 0)
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_BACKGROUND );
     }
@@ -3936,7 +3941,7 @@ void SwWW8ImplReader::Read_TextBackColor(sal_uInt16, 
const sal_uInt8* pData, sho
 
 void SwWW8ImplReader::Read_CharHighlight(sal_uInt16, const sal_uInt8* pData, 
short nLen)
 {
-    if( nLen <= 0 )
+    if (nLen < 1)
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_HIGHLIGHT );
     }
@@ -3954,7 +3959,7 @@ void SwWW8ImplReader::Read_CharHighlight(sal_uInt16, 
const sal_uInt8* pData, sho
 
 void SwWW8ImplReader::Read_NoLineNumb(sal_uInt16 , const sal_uInt8* pData, 
short nLen)
 {
-    if( nLen < 0 )  // end of attribute
+    if (nLen < 0)  // end of attribute
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_LINENUMBER );
         return;
@@ -3966,7 +3971,7 @@ void SwWW8ImplReader::Read_NoLineNumb(sal_uInt16 , const 
sal_uInt8* pData, short
         aLN.SetStartValue( pLN->GetStartValue() );
     }
 
-    aLN.SetCountLines( pData && (0 == *pData) );
+    aLN.SetCountLines(pData && nLen >= 1 && (0 == *pData));
     NewAttr( aLN );
 }
 
@@ -3982,10 +3987,11 @@ bool lcl_HasExplicitLeft(const WW8PLCFMan *pPlcxMan, 
bool bVer67)
     }
     return false;
 }
+
 // Sprm 16, 17
 void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short 
nLen )
 {
-    if (nLen < 0)  // end of attribute
+    if (nLen < 2)  // end of attribute
     {
         m_pCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_LR_SPACE);
         return;
@@ -4136,7 +4142,10 @@ void SwWW8ImplReader::Read_LineSpace( sal_uInt16, const 
sal_uInt8* pData, short
     if (m_bStyNormal && m_bWWBugNormal)
         return;
 
-    if( nLen < 0 ){
+    ww::WordVersion eVersion = m_pWwFib->GetFIBVersion();
+
+    if (nLen < ((eVersion <= ww::eWW2) ? 3 : 4))
+    {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_PARATR_LINESPACING );
         if( !( m_nIniFlags & WW8FL_NO_IMPLPASP ) )
             m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_UL_SPACE );
@@ -4144,7 +4153,6 @@ void SwWW8ImplReader::Read_LineSpace( sal_uInt16, const 
sal_uInt8* pData, short
     }
 
     short nSpace = SVBT16ToShort( pData );
-    ww::WordVersion eVersion = m_pWwFib->GetFIBVersion();
     short nMulti = (eVersion <= ww::eWW2) ? 1 : SVBT16ToShort( pData + 2 );
 
     SvxLineSpaceRule eLnSpc;
@@ -4204,7 +4212,7 @@ sal_uInt16 SwWW8ImplReader::GetParagraphAutoSpace(bool 
fDontUseHTMLAutoSpacing)
 
 void SwWW8ImplReader::Read_ParaAutoBefore(sal_uInt16, const sal_uInt8 *pData, 
short nLen)
 {
-    if (nLen < 0)
+    if (nLen < 1)
     {
         m_pCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_UL_SPACE);
         return;
@@ -4231,7 +4239,7 @@ void SwWW8ImplReader::Read_ParaAutoBefore(sal_uInt16, 
const sal_uInt8 *pData, sh
 
 void SwWW8ImplReader::Read_ParaAutoAfter(sal_uInt16, const sal_uInt8 *pData, 
short nLen)
 {
-    if (nLen < 0)
+    if (nLen < 1)
     {
         m_pCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_UL_SPACE);
         return;
@@ -4270,7 +4278,7 @@ void SwWW8ImplReader::Read_UL( sal_uInt16 nId, const 
sal_uInt8* pData, short nLe
     // then please send this Document to SH.");
     // bWWBugNormal is not a sufficient criterion for this distance being 
wrong.
 
-    if( nLen < 0 )
+    if (nLen < 2)
     {
         // end of attribute
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_UL_SPACE );
@@ -4303,7 +4311,7 @@ void SwWW8ImplReader::Read_UL( sal_uInt16 nId, const 
sal_uInt8* pData, short nLe
 
 void SwWW8ImplReader::Read_ParaContextualSpacing( sal_uInt16, const sal_uInt8* 
pData, short nLen )
 {
-    if( nLen < 0 )
+    if (nLen < 1)
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_UL_SPACE );
         return;
@@ -4321,7 +4329,7 @@ void SwWW8ImplReader::Read_IdctHint( sal_uInt16, const 
sal_uInt8* pData, short n
     // when this value is 0, text properties bias towards non-far east 
properties.
     // when this value is 1, text properties bias towards far east properties.
     // when this value is 2, text properties bias towards complex properties.
-    if( nLen < 0 )  //Property end
+    if (nLen < 1)  //Property end
     {
         m_pCtrlStck->SetAttr(*m_pPaM->GetPoint(),RES_CHRATR_IDCTHINT);
     }
@@ -4333,7 +4341,7 @@ void SwWW8ImplReader::Read_IdctHint( sal_uInt16, const 
sal_uInt8* pData, short n
 
 void SwWW8ImplReader::Read_Justify( sal_uInt16, const sal_uInt8* pData, short 
nLen )
 {
-    if( nLen < 0 )
+    if (nLen < 1)
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_PARATR_ADJUST );
         return;
@@ -4386,7 +4394,7 @@ bool SwWW8ImplReader::IsRightToLeft()
 
 void SwWW8ImplReader::Read_RTLJustify( sal_uInt16, const sal_uInt8* pData, 
short nLen )
 {
-    if( nLen < 0 )
+    if (nLen < 1)
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_PARATR_ADJUST );
         return;
@@ -4445,7 +4453,7 @@ void SwWW8ImplReader::Read_BoolItem( sal_uInt16 nId, 
const sal_uInt8* pData, sho
             return ;
     }
 
-    if( nLen < 0 )
+    if (nLen < 1)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), nId );
     else
     {
@@ -4458,7 +4466,7 @@ void SwWW8ImplReader::Read_BoolItem( sal_uInt16 nId, 
const sal_uInt8* pData, sho
 
 void SwWW8ImplReader::Read_Emphasis( sal_uInt16, const sal_uInt8* pData, short 
nLen )
 {
-    if( nLen < 0 )
+    if (nLen < 1)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_EMPHASIS_MARK );
     else
     {
@@ -4515,7 +4523,7 @@ void SwWW8ImplReader::Read_Emphasis( sal_uInt16, const 
sal_uInt8* pData, short n
 
 void SwWW8ImplReader::Read_ScaleWidth( sal_uInt16, const sal_uInt8* pData, 
short nLen )
 {
-    if( nLen < 0 )
+    if (nLen < 2)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_SCALEW );
     else
     {
@@ -4529,7 +4537,7 @@ void SwWW8ImplReader::Read_ScaleWidth( sal_uInt16, const 
sal_uInt8* pData, short
 
 void SwWW8ImplReader::Read_Relief( sal_uInt16 nId, const sal_uInt8* pData, 
short nLen )
 {
-    if( nLen < 0 )
+    if (nLen < 1)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_RELIEF );
     else
     {
@@ -4556,7 +4564,7 @@ void SwWW8ImplReader::Read_Relief( sal_uInt16 nId, const 
sal_uInt8* pData, short
 
 void SwWW8ImplReader::Read_TextAnim(sal_uInt16 /*nId*/, const sal_uInt8* 
pData, short nLen)
 {
-    if (nLen < 0)
+    if (nLen < 1)
         m_pCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_CHRATR_BLINK);
     else
     {
@@ -4718,7 +4726,7 @@ void SwWW8ImplReader::Read_Shade( sal_uInt16, const 
sal_uInt8* pData, short nLen
     if (!m_bVer67 && m_pPlcxMan && m_pPlcxMan->GetPapPLCF()->HasSprm(0xC64D))
         return;
 
-    if (nLen <= 0)
+    if (nLen < 2)
     {
         // end of attribute
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_BACKGROUND );
@@ -4794,7 +4802,7 @@ void SwWW8ImplReader::Read_TextVerticalAdjustment( 
sal_uInt16, const sal_uInt8*
 
 void SwWW8ImplReader::Read_Border(sal_uInt16 , const sal_uInt8*, short nLen)
 {
-    if( nLen < 0 )
+    if (nLen < 0)
     {
         if( m_bHasBorder )
         {
@@ -4870,7 +4878,7 @@ void SwWW8ImplReader::Read_CharBorder(sal_uInt16 nId, 
const sal_uInt8* pData, sh
     //if (!bVer67 && pPlcxMan && pPlcxMan->GetChpPLCF()->HasSprm(0xCA72))
     //    return;
 
-    if( nLen < 0 )
+    if (nLen < 0)
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_BOX );
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_SHADOW );
@@ -4910,7 +4918,7 @@ void SwWW8ImplReader::Read_CharBorder(sal_uInt16 nId, 
const sal_uInt8* pData, sh
 void SwWW8ImplReader::Read_Hyphenation( sal_uInt16, const sal_uInt8* pData, 
short nLen )
 {
     // set Hyphenation flag
-    if( nLen <= 0 )
+    if (nLen < 1)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_PARATR_HYPHENZONE );
     else
     {
@@ -4932,7 +4940,7 @@ void SwWW8ImplReader::Read_Hyphenation( sal_uInt16, const 
sal_uInt8* pData, shor
 
 void SwWW8ImplReader::Read_WidowControl( sal_uInt16, const sal_uInt8* pData, 
short nLen )
 {
-    if( nLen <= 0 )
+    if (nLen < 1)
     {
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_PARATR_WIDOWS );
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_PARATR_ORPHANS );
@@ -4952,7 +4960,7 @@ void SwWW8ImplReader::Read_WidowControl( sal_uInt16, 
const sal_uInt8* pData, sho
 
 void SwWW8ImplReader::Read_UsePgsuSettings(sal_uInt16,const sal_uInt8* 
pData,short nLen)
 {
-    if( nLen <= 0 )
+    if (nLen < 1)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_PARATR_SNAPTOGRID);
     else
     {
@@ -4965,7 +4973,7 @@ void 
SwWW8ImplReader::Read_UsePgsuSettings(sal_uInt16,const sal_uInt8* pData,sho
 
 void SwWW8ImplReader::Read_AlignFont( sal_uInt16, const sal_uInt8* pData, 
short nLen )
 {
-    if( nLen <= 0 )
+    if (nLen < 2)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_PARATR_VERTALIGN);
     else
     {
@@ -4999,7 +5007,7 @@ void SwWW8ImplReader::Read_AlignFont( sal_uInt16, const 
sal_uInt8* pData, short
 
 void SwWW8ImplReader::Read_KeepLines( sal_uInt16, const sal_uInt8* pData, 
short nLen )
 {
-    if( nLen <= 0 )
+    if (nLen < 1)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_PARATR_SPLIT );
     else
         NewAttr( SvxFormatSplitItem( ( *pData & 1 ) == 0, RES_PARATR_SPLIT ) );
@@ -5007,7 +5015,7 @@ void SwWW8ImplReader::Read_KeepLines( sal_uInt16, const 
sal_uInt8* pData, short
 
 void SwWW8ImplReader::Read_KeepParas( sal_uInt16, const sal_uInt8* pData, 
short nLen )
 {
-    if( nLen <= 0 )
+    if (nLen < 1)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_KEEP );
     else
         NewAttr( SvxFormatKeepItem( ( *pData & 1 ) != 0 , RES_KEEP) );
@@ -5015,7 +5023,7 @@ void SwWW8ImplReader::Read_KeepParas( sal_uInt16, const 
sal_uInt8* pData, short
 
 void SwWW8ImplReader::Read_BreakBefore( sal_uInt16, const sal_uInt8* pData, 
short nLen )
 {
-    if( nLen <= 0 )
+    if (nLen < 1)
         m_pCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_BREAK );
     else
         NewAttr( SvxFormatBreakItem(
commit 537469f2294742fcd770b162ad965ad1c09cd72e
Author: Caolán McNamara <caol...@redhat.com>
Date:   Thu Apr 6 16:15:30 2017 +0100

    crashtesting: empty ReadAccess on converting fdo58541-1.xls to pdf
    
    Change-Id: I72c74c7224e99b090eceb8928eeddc3b50d1d2c8

diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index ec534784c3d8..6af9bcd37730 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -1109,7 +1109,7 @@ Bitmap Bitmap::CreateMask( const Color& rTransColor, 
sal_uLong nTol ) const
 {
     ScopedReadAccess pReadAcc(const_cast<Bitmap&>(*this));
 
-    if (!nTol && (pReadAcc->GetScanlineFormat() == ScanlineFormat::N1BitLsbPal 
|| pReadAcc->GetScanlineFormat() == ScanlineFormat::N1BitMsbPal)
+    if (!nTol && pReadAcc && (pReadAcc->GetScanlineFormat() == 
ScanlineFormat::N1BitLsbPal || pReadAcc->GetScanlineFormat() == 
ScanlineFormat::N1BitMsbPal)
         && pReadAcc->GetBestMatchingColor(Color(COL_WHITE)) == 
pReadAcc->GetBestMatchingColor(rTransColor))
     {
         //if we're a 1 bit pixel already, and the transcolor matches the color 
that would replace it already already, then just return a copy
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to