drawinglayer/inc/texture/texture3d.hxx    |    4 +---
 drawinglayer/source/texture/texture3d.cxx |   29 +++++++++++++----------------
 2 files changed, 14 insertions(+), 19 deletions(-)

New commits:
commit b926ef35afb8b4c6372723a4ae407025750ee6f2
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Jun 6 11:49:49 2025 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Jun 6 16:23:37 2025 +0200

    null deref of empty AlphaMask
    
     (gdb) print 
mpReadTransparence.moAccess._M_payload._M_payload._M_value.mpBuffer
     $18 = (BitmapBuffer *) 0x0
    
     #0  BitmapReadAccess::GetScanline (this=<optimized out>, nY=<optimized 
out>) at /opt/rh/devtoolset-12/root/usr/include/c++/12/optional:484
     #1  BitmapReadAccess::GetPixel (nX=<optimized out>, nY=<optimized out>, 
this=<optimized out>) at include/vcl/BitmapReadAccess.hxx:83
     #2  drawinglayer::texture::GeoTexSvxBitmapEx::impGetAlpha 
(this=this@entry=0x3a073610, rX=rX@entry=60, rY=rY@entry=420)
         at drawinglayer/source/texture/texture3d.cxx:111
     #3  0x00007f4cc4baba0e in 
drawinglayer::texture::GeoTexSvxBitmapEx::impGetAlpha (rY=420, rX=<optimized 
out>, this=0x3a073610)
         at drawinglayer/source/texture/texture3d.cxx:152
     #4  drawinglayer::texture::GeoTexSvxBitmapEx::modifyBColor 
(this=0x3a073610, rUV=..., rBColor=..., rfOpacity=@0x7f4cabbba638: 1)
         at drawinglayer/source/texture/texture3d.cxx:152
     #5  0x00007f4cc4ba9a31 in ZBufferRasterConverter3D::decideColorAndOpacity 
(this=this@entry=0x39db6260, rColor=...)
         at drawinglayer/source/processor3d/zbufferprocessor3d.cxx:119
     #6  0x00007f4cc4ba4d9c in ZBufferRasterConverter3D::processLineSpan 
(this=0x39db6260, rA=..., rB=..., nLine=<optimized out>, nSpanCount=<optimized 
out>)
         at drawinglayer/source/processor3d/zbufferprocessor3d.cxx:305
     #7  0x00007f4cc438d5f6 in 
basegfx::RasterConverter3D::rasterconvertB3DArea(int, int) ()
         at basegfx/source/raster/rasterconvert3d.cxx:129
     #8  0x00007f4cc4ba0ac7 in 
drawinglayer::processor3d::DefaultProcessor3D::impRenderPolyPolygonMaterialPrimitive3D(drawinglayer::primitive3d::PolyPolygonMaterialPrimitive3D
 const&) const ()
         at drawinglayer/source/processor3d/defaultprocessor3d.cxx:448
     #9  0x00007f4cc4b9fcc9 in 
drawinglayer::processor3d::BaseProcessor3D::process 
(this=this@entry=0x39da04c0, rSource=...) at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/stl_deque.h:263
     #10 0x00007f4cc4ba1ca0 in 
drawinglayer::processor3d::DefaultProcessor3D::impRenderBitmapTexturePrimitive3D(drawinglayer::primitive3d::BitmapTexturePrimitive3D
 const&) ()
         at drawinglayer/source/processor3d/defaultprocessor3d.cxx:263
     #11 0x00007f4cc4b9fcc9 in 
drawinglayer::processor3d::BaseProcessor3D::process 
(this=this@entry=0x39da04c0, rSource=...) at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/stl_deque.h:263
     #12 0x00007f4cc4ba2846 in 
drawinglayer::processor3d::DefaultProcessor3D::processBasePrimitive3D(drawinglayer::primitive3d::BasePrimitive3D
 const&) ()
         at include/drawinglayer/processor3d/baseprocessor3d.hxx:63
     #13 0x00007f4cc4b9fcc9 in 
drawinglayer::processor3d::BaseProcessor3D::process (this=0x39da04c0, 
rSource=...) at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/stl_deque.h:263
     #14 0x00007f4cc4b3a225 in 
drawinglayer::primitive2d::ScenePrimitive2D::Executor::doWork (this=0x39e13950) 
at /opt/rh/devtoolset-12/root/usr/include/c++/12/bits/unique_ptr.h:461
     #15 0x00007f4cc4868fe7 in comphelper::ThreadTask::exec() () at 
comphelper/source/misc/threadpool.cxx:319
     #16 0x00007f4cc4869c61 in comphelper::ThreadPool::ThreadWorker::execute 
(this=0x39e13aa0) at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/unique_ptr.h:461
     #17 0x00007f4cc144f33f in salhelper::Thread::run() () at 
salhelper/source/thread.cxx:39
     #18 0x00007f4cc144fe94 in osl::threadFunc (param=0x39e13ab0) at 
include/osl/thread.hxx:189
     #19 0x00007f4cc14e0563 in osl_thread_start_Impl (pData=0x39120800) at 
sal/osl/unx/thread.cxx:237
     #20 0x00007f4ccae5f6db in start_thread (arg=0x7f4cabbcb700) at 
pthread_create.c:463
     #21 0x00007f4ccab8874f in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:95
    
    Change-Id: Ic30b38dc1c53c9df551a282c6a057d042265419e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186222
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/drawinglayer/inc/texture/texture3d.hxx 
b/drawinglayer/inc/texture/texture3d.hxx
index 1ec4df70734c..324c204ed526 100644
--- a/drawinglayer/inc/texture/texture3d.hxx
+++ b/drawinglayer/inc/texture/texture3d.hxx
@@ -62,11 +62,9 @@ namespace drawinglayer::texture
             double                                      mfMulX;
             double                                      mfMulY;
 
-            bool                                        mbIsAlpha : 1;
-
             // helpers
             bool impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, 
sal_Int32& rY) const;
-            sal_uInt8 impGetAlpha(sal_Int32 rX, sal_Int32 rY) const;
+            static sal_uInt8 impGetAlpha(const BitmapReadAccess& 
readTransparence, sal_Int32 rX, sal_Int32 rY);
 
         public:
             GeoTexSvxBitmapEx(
diff --git a/drawinglayer/source/texture/texture3d.cxx 
b/drawinglayer/source/texture/texture3d.cxx
index 4cbcab9d1c5d..9566e73abd03 100644
--- a/drawinglayer/source/texture/texture3d.cxx
+++ b/drawinglayer/source/texture/texture3d.cxx
@@ -65,18 +65,19 @@ namespace drawinglayer::texture
             maTopLeft(rRange.getMinimum()),
             maSize(rRange.getRange()),
             mfMulX(0.0),
-            mfMulY(0.0),
-            mbIsAlpha(maBitmapEx.IsAlpha())
+            mfMulY(0.0)
         {
+            bool bIsAlpha(maBitmapEx.IsAlpha());
             if(vcl::bitmap::convertBitmap32To24Plus8(maBitmapEx,maBitmapEx))
-                mbIsAlpha = maBitmapEx.IsAlpha();
+                bIsAlpha = maBitmapEx.IsAlpha();
             // #121194# Todo: use alpha channel, too (for 3d)
             maBitmap = maBitmapEx.GetBitmap();
 
-            if(mbIsAlpha)
+            if (bIsAlpha)
             {
                 maTransparence = rBitmapEx.GetAlphaMask().GetBitmap();
                 mpReadTransparence = maTransparence;
+                OSL_ENSURE(mpReadTransparence, "OOps, transparence type 
Bitmap, but no read access created in the constructor (?)");
             }
 
             if (!maBitmap.IsEmpty())
@@ -103,15 +104,11 @@ namespace drawinglayer::texture
         {
         }
 
-        sal_uInt8 GeoTexSvxBitmapEx::impGetAlpha(sal_Int32 rX, sal_Int32 rY) 
const
+        //static
+        sal_uInt8 GeoTexSvxBitmapEx::impGetAlpha(const BitmapReadAccess& 
readTransparence, sal_Int32 rX, sal_Int32 rY)
         {
-            if(mbIsAlpha)
-            {
-                OSL_ENSURE(mpReadTransparence, "OOps, transparence type 
Bitmap, but no read access created in the constructor (?)");
-                const BitmapColor 
aBitmapColor(mpReadTransparence->GetPixel(rY, rX));
-                return aBitmapColor.GetIndex();
-            }
-            return 0;
+            const BitmapColor aBitmapColor(readTransparence.GetPixel(rY, rX));
+            return aBitmapColor.GetIndex();
         }
 
         bool GeoTexSvxBitmapEx::impIsValid(const basegfx::B2DPoint& rUV, 
sal_Int32& rX, sal_Int32& rY) const
@@ -146,10 +143,10 @@ namespace drawinglayer::texture
 
                 rBColor = aBSource;
 
-                if(mbIsAlpha)
+                if (mpReadTransparence)
                 {
                     // when we have alpha, make use of it
-                    const sal_uInt8 aAlpha(impGetAlpha(nX, nY));
+                    const sal_uInt8 aAlpha(impGetAlpha(*mpReadTransparence, 
nX, nY));
 
                     rfOpacity = (static_cast<double>(aAlpha) * (1.0 / 255.0));
                 }
@@ -170,10 +167,10 @@ namespace drawinglayer::texture
 
             if(impIsValid(rUV, nX, nY))
             {
-                if(mbIsAlpha)
+                if (mpReadTransparence)
                 {
                     // this texture has an alpha part, use it
-                    const sal_uInt8 aAlpha(impGetAlpha(nX, nY));
+                    const sal_uInt8 aAlpha(impGetAlpha(*mpReadTransparence, 
nX, nY));
                     const double fNewOpacity(static_cast<double>(aAlpha) * 
(1.0 / 255.0));
 
                     rfOpacity = 1.0 - ((1.0 - fNewOpacity) * (1.0 - 
rfOpacity));

Reply via email to