Author: orw
Date: Thu Jun 19 09:55:51 2014
New Revision: 1603801

URL: http://svn.apache.org/r1603801
Log:
125000: <WinSalBitmap::ImplCreateGdiPlusBitmap()> - check last status of newly 
created <Gdiplus::Bitmap> instance before using it.

        cherry-picked from trunk


Modified:
    openoffice/branches/AOO410/   (props changed)
    openoffice/branches/AOO410/main/   (props changed)
    openoffice/branches/AOO410/main/vcl/win/source/gdi/salbmp.cxx

Propchange: openoffice/branches/AOO410/
------------------------------------------------------------------------------
  Merged /openoffice/trunk:r1600861

Propchange: openoffice/branches/AOO410/main/
------------------------------------------------------------------------------
  Merged /openoffice/trunk/main:r1600861

Modified: openoffice/branches/AOO410/main/vcl/win/source/gdi/salbmp.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/AOO410/main/vcl/win/source/gdi/salbmp.cxx?rev=1603801&r1=1603800&r2=1603801&view=diff
==============================================================================
--- openoffice/branches/AOO410/main/vcl/win/source/gdi/salbmp.cxx (original)
+++ openoffice/branches/AOO410/main/vcl/win/source/gdi/salbmp.cxx Thu Jun 19 
09:55:51 2014
@@ -310,24 +310,32 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreat
 
         if(pRetval)
         {
-            sal_uInt8* pSrcRGB(pRGB->mpBits);
-            const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3));
-            const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN);
-            const Gdiplus::Rect aAllRect(0, 0, nW, nH);
-            Gdiplus::BitmapData aGdiPlusBitmapData;
-            pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, 
PixelFormat24bppRGB, &aGdiPlusBitmapData);
-
-            // copy data to Gdiplus::Bitmap; format is BGR here in both cases, 
so memcpy is possible
-            for(sal_uInt32 y(0); y < nH; y++)
+            if ( pRetval->GetLastStatus() == Gdiplus::Ok )
             {
-                const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1);
-                sal_uInt8* targetPixels = (sal_uInt8*)aGdiPlusBitmapData.Scan0 
+ (nYInsert * aGdiPlusBitmapData.Stride);
+                sal_uInt8* pSrcRGB(pRGB->mpBits);
+                const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3));
+                const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN);
+                const Gdiplus::Rect aAllRect(0, 0, nW, nH);
+                Gdiplus::BitmapData aGdiPlusBitmapData;
+                pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, 
PixelFormat24bppRGB, &aGdiPlusBitmapData);
 
-                memcpy(targetPixels, pSrcRGB, nW * 3);
-                pSrcRGB += nW * 3 + nExtraRGB;
-            }
+                // copy data to Gdiplus::Bitmap; format is BGR here in both 
cases, so memcpy is possible
+                for(sal_uInt32 y(0); y < nH; y++)
+                {
+                    const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1);
+                    sal_uInt8* targetPixels = 
(sal_uInt8*)aGdiPlusBitmapData.Scan0 + (nYInsert * aGdiPlusBitmapData.Stride);
 
-            pRetval->UnlockBits(&aGdiPlusBitmapData);
+                    memcpy(targetPixels, pSrcRGB, nW * 3);
+                    pSrcRGB += nW * 3 + nExtraRGB;
+                }
+
+                pRetval->UnlockBits(&aGdiPlusBitmapData);
+            }
+            else
+            {
+                delete pRetval;
+                pRetval = NULL;
+            }
         }
     }
 


Reply via email to