vcl/source/font/fontmetric.cxx |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit e9b5518b4c53cf67860a504f2f1b823625b03788
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed May 11 08:05:55 2022 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Wed May 11 11:05:54 2022 +0200

    Don't leave ImplFontMetricData::mnHangingBaseline uninitialized
    
    ...after 5f92e8cf3da6b5f66b6ef23219fcc91d2ad7c754 "tdf#104930 Implement
    TextMetric::GetHangingBaseline", to avoid UBSan failures like
    
    > [_RUN_____] (anonymous namespace)::Test::testLineSpacing
    > /vcl/source/outdev/map.cxx:291:9: runtime error: signed integer overflow: 
-4702111234474983746 * 1440 cannot be represented in type 'long'
    >     #0 0x7f408a2ba5fe in ImplPixelToLogic(long, long, long, long) 
/vcl/source/outdev/map.cxx:291:9
    >     #1 0x7f408a2bac1e in OutputDevice::ImplDevicePixelToLogicHeight(long) 
const /vcl/source/outdev/map.cxx:361:12
    >     #2 0x7f408a136ddc in OutputDevice::GetFontMetric() const 
/vcl/source/outdev/font.cxx:217:33
    
    during CppunitTest_editeng (<https://ci.libreoffice.org/job/lo_ubsan/2395/>)
    
    Change-Id: Ief2121c588d296a23606314143a0176c8ae9aa38
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134142
    Reviewed-by: Mark Hung <mark...@gmail.com>
    Tested-by: Jenkins

diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx
index 0021c454fa99..dfc005b6a9d6 100644
--- a/vcl/source/font/fontmetric.cxx
+++ b/vcl/source/font/fontmetric.cxx
@@ -427,6 +427,10 @@ void 
ImplFontMetricData::ImplInitBaselines(LogicalFontInstance *pFontInstance)
     {
         mnHangingBaseline = nBaseline * fScale;
     }
+    else
+    {
+        mnHangingBaseline = 0;
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to