diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-03-31 18:11:27 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-03-31 18:10:42 +0200 |
commit | 5e30823e8a25066aa7bbaa801583dbfa7db55a72 (patch) | |
tree | 2c068bbd76ac560779737ccebf6925f5cdc3d54e /embeddedobj | |
parent | 3b25ea6d83041c03d06a47fb5e278372181b8a6d (diff) |
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@collabora.com>
Diffstat (limited to 'embeddedobj')
-rw-r--r-- | embeddedobj/source/msole/olecomponent.cxx | 8 |
1 files changed, 7 insertions, 1 deletions
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() ) ) ) { |