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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Sep 18 06:42:40 UTC 2018


 sc/source/core/data/colorscale.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 5be8dbd98b09b73319a7c5baf0473c29cd5d05b6
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Sep 18 07:33:39 2018 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Sep 18 08:42:18 2018 +0200

    Don't prematurely cast to sal_uInt8, to avoid UB
    
    ...e.g. during UITest_conditional_format
    (https://ci.libreoffice.org//job/lo_ubsan/1039/):
    
    > /sc/source/core/data/colorscale.cxx:524:48: runtime error: value -33.2609 is outside the range of representable values of type 'unsigned char'
    >     #0 0x2b778b7d666d in (anonymous namespace)::GetColorValue(double, double, unsigned char, double, unsigned char) /sc/source/core/data/colorscale.cxx:524:48
    >     #1 0x2b778b7bd096 in (anonymous namespace)::CalcColor(double, double, Color const&, double, Color const&) /sc/source/core/data/colorscale.cxx:530:25
    >     #2 0x2b778b7bcb94 in ScColorScaleFormat::GetColor(ScAddress const&) const /sc/source/core/data/colorscale.cxx:625:20
    >     #3 0x2b778b8906a4 in ScConditionalFormat::GetData(ScRefCellValue&, ScAddress const&) const /sc/source/core/data/conditio.cxx:1830:33
    >     #4 0x2b778cb8968a in (anonymous namespace)::handleConditionalFormat(ScConditionalFormatList&, std::__debug::vector<unsigned int, std::allocator<unsigned int> > const&, CellInfo*, ScStyleSheetPool*, ScAddress const&, bool&, bool&, bool) /sc/source/core/data/fillinfo.cxx:301:34
    >     #5 0x2b778cb74e49 in ScDocument::FillInfo(ScTableInfo&, short, int, short, int, short, double, double, bool, bool, ScMarkData const*) /sc/source/core/data/fillinfo.cxx:581:54
    >     #6 0x2b77941656c0 in ScPrintFunc::DrawToDev(ScDocument*, OutputDevice*, double, tools::Rectangle const&, ScViewData*, bool) /sc/source/ui/view/printfun.cxx:539:5
    >     #7 0x2b77914e965b in ScDocShell::Draw(OutputDevice*, JobSetup const&, unsigned short) /sc/source/ui/docshell/docsh4.cxx:2032:9
    >     #8 0x2b76f7004296 in SfxObjectShell::DoDraw_Impl(OutputDevice*, Point const&, Fraction const&, Fraction const&, JobSetup const&, unsigned short) /sfx2/source/doc/objembed.cxx:229:5
    >     #9 0x2b76f7001b81 in SfxObjectShell::DoDraw(OutputDevice*, Point const&, Size const&, JobSetup const&, unsigned short) /sfx2/source/doc/objembed.cxx:176:9
    >     #10 0x2b76f6fd8fe3 in SfxObjectShell::CreatePreviewMetaFile_Impl(bool) const /sfx2/source/doc/objcont.cxx:168:5
    >     #11 0x2b76f6fd618b in SfxObjectShell::GetPreviewMetaFile(bool) const /sfx2/source/doc/objcont.cxx:115:12
    >     #12 0x2b76f55728ab in SfxPickListImpl::AddDocumentToPickList(SfxObjectShell*) /sfx2/source/appl/sfxpicklist.cxx:134:54
    >     #13 0x2b76f5576d93 in SfxPickListImpl::Notify(SfxBroadcaster&, SfxHint const&) /sfx2/source/appl/sfxpicklist.cxx:222:17
    >     #14 0x2b76fc444921 in SfxBroadcaster::Broadcast(SfxHint const&) /svl/source/notify/SfxBroadcaster.cxx:49:13
    >     #15 0x2b76f4eb062c in SfxEventAsyncer_Impl::IdleHdl(Timer*) /sfx2/source/appl/appcfg.cxx:119:5
    >     #16 0x2b76f4eaf705 in SfxEventAsyncer_Impl::LinkStubIdleHdl(void*, Timer*) /sfx2/source/appl/appcfg.cxx:114:1
    >     #17 0x2b7724e683b7 in Link<Timer*, void>::Call(Timer*) const /include/tools/link.hxx:84:45
    >     #18 0x2b7724e67599 in Timer::Invoke() /vcl/source/app/timer.cxx:77:5
    >     #19 0x2b7724c40779 in Scheduler::ProcessTaskScheduling() /vcl/source/app/scheduler.cxx:451:13
    >     #20 0x2b7724c3b168 in Scheduler::CallbackTaskScheduling() /vcl/source/app/scheduler.cxx:270:5
    >     #21 0x2b7725b02fac in SalTimer::CallCallback() /vcl/inc/saltimer.hxx:55:13
    >     #22 0x2b7725af43a5 in SvpSalInstance::CheckTimeout(bool) /vcl/headless/svpinst.cxx:206:21
    >     #23 0x2b7725afbc52 in SvpSalInstance::DoYield(bool, bool) /vcl/headless/svpinst.cxx:418:14
    >     #24 0x2b7724dafc3b in ImplYield(bool, bool) /vcl/source/app/svapp.cxx:471:28
    >     #25 0x2b7724d8a3ff in Application::Yield() /vcl/source/app/svapp.cxx:536:5
    [...]
    
    Change-Id: I1650c2236a183c7b6349be6cb444d350e85ea8b6
    Reviewed-on: https://gerrit.libreoffice.org/60654
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 46dea0e3f124..7b79ec56beb8 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -521,7 +521,7 @@ sal_uInt8 GetColorValue( double nVal, double nVal1, sal_uInt8 nColVal1, double n
     if (nVal >= nVal2)
         return nColVal2;
 
-    sal_uInt8 nColVal = static_cast<sal_uInt8>((nVal - nVal1)/(nVal2-nVal1)*(nColVal2-nColVal1))+nColVal1;
+    sal_uInt8 nColVal = static_cast<int>((nVal - nVal1)/(nVal2-nVal1)*(nColVal2-nColVal1))+nColVal1;
     return nColVal;
 }
 


More information about the Libreoffice-commits mailing list