[Libreoffice-commits] core.git: embeddedobj/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Sun Mar 31 16:11:03 UTC 2019


 embeddedobj/source/msole/olecomponent.cxx |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 5e30823e8a25066aa7bbaa801583dbfa7db55a72
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Mar 31 18:11:27 2019 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Mar 31 18:10:42 2019 +0200

    tdf#120703 PVS: GetBitmapBits does not return required buffer size
    
    ... unlike GetMetaFileBitsEx or GetEnhMetaFileBits, which are used
    in the other branches. The implementation is trying to pass nullptr
    to the function since commit 41e72962df83a410986fb48250aaaf1adc827c13
    
    Just calculate the required buffer size using BITMAP struct filled
    by GetObject call.
    
    V575 The null pointer is passed into 'GetBitmapBits' function.
         Inspect the third argument.
    
    Change-Id: I0d164694c99d805fd59b65ea1b4df4919a89e130
    Reviewed-on: https://gerrit.libreoffice.org/70012
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx
index a8fad97a35a7..f1511d696f7b 100644
--- a/embeddedobj/source/msole/olecomponent.cxx
+++ b/embeddedobj/source/msole/olecomponent.cxx
@@ -334,7 +334,13 @@ bool OleComponentNative_Impl::ConvertDataForFlavor( const STGMEDIUM& aMedium,
         else if ( aMedium.tymed == TYMED_GDI ) // Bitmap
         {
             aFormat = "image/x-MS-bmp";
-            nBufSize = GetBitmapBits( aMedium.hBitmap, 0, nullptr );
+
+            // Find out size of buffer: deprecated GetBitmapBits does not have a mode to return
+            // required buffer size
+            BITMAP aBmp;
+            GetObjectW(aMedium.hBitmap, sizeof(aBmp), &aBmp);
+            nBufSize = aBmp.bmWidthBytes * aBmp.bmHeight;
+
             pBuf.reset(new sal_Int8[nBufSize]);
             if ( nBufSize && nBufSize == sal::static_int_cast< ULONG >( GetBitmapBits( aMedium.hBitmap, nBufSize, pBuf.get() ) ) )
             {


More information about the Libreoffice-commits mailing list