sfx2/source/control/thumbnailview.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
New commits: commit 28d844a589e52abfe62dc66b888e78665221ba28 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Mon Feb 17 09:29:12 2020 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Mon Feb 17 10:12:50 2020 +0100 Fix failed assertion "value >= 0" in o3tl::make_unsigned ...after b2945902e7a0ad9f033fe67f5ab217d6e31d8d84 "Avoid explicit casts to smaller sal_uInt16 from larger long": As Mike Kaganski reported at <https://gerrit.libreoffice.org/c/core/+/87442/2# message-bc3d33b177eecba4255e299ac92c2f0c1712b57d>, clicking on "Templates" in the start center causes the assert to fire at > #3 0x00007ffff6296a66 in __GI___assert_fail > #4 0x00007fffe6b11df8 in _ZN4o3tl13make_unsignedIlEENSt9enable_ifIXsr3stdE11is_signed_vIT_EENSt13make_unsignedIS2_E4typeEE4typeES2_ (value=-1) at include/o3tl/safeint.hxx:233 > #5 0x00007fffe6ad75f6 in ThumbnailView::SelectItem(unsigned short) (this=0x61a0000fc680, nItemId=1) at sfx2/source/control/thumbnailview.cxx:1011 > #6 0x00007fffe6ade62c in ThumbnailView::GetFocus() (this=0x61a0000fc680) at sfx2/source/control/thumbnailview.cxx:838 > #7 0x00007fffc27c292b in vcl::Window::CompatGetFocus() (this=0x61a0000fc680) at vcl/source/window/window.cxx:3895 > #8 0x00007fffc226604e in vcl::Window::ImplGrabFocus(GetFocusFlags) (this=0x61a0000fc680, nFlags=GetFocusFlags::NONE) at vcl/source/window/mouse.cxx:378 > #9 0x00007fffc2738071 in vcl::Window::GrabFocus() (this=0x61a0000fc680) at vcl/source/window/window.cxx:3029 > #10 0x00007fffe6c4a529 in BackingWindow::ClickHdl(Button*) (this=0x6190005e8880, pButton=0x61800031a080) at sfx2/source/dialog/backingwindow.cxx:585 > #11 0x00007fffe6c3c1eb in BackingWindow::LinkStubClickHdl(void*, Button*) (instance=0x6190005e8880, data=0x61800031a080) at sfx2/source/dialog/backingwindow.cxx:535 > #12 0x00007fffc2937f72 in Link<Button*, void>::Call(Button*) const (this=0x61800031a328, data=0x61800031a080) at include/tools/link.hxx:111 > #13 0x00007fffc291c13c in Button::Click()::$_0::operator()() const (this=0x7fff8c0ce0a0) at vcl/source/control/button.cxx:123 when mnFirstLine and mnVisLines are both 0. (And nNewLine is 0 because nItemPos is 0. An alternative fix might be to replace else if ( nNewLine > o3tl::make_unsigned(mnFirstLine+mnVisLines-1) ) with else if ( nNewLine >= o3tl::make_unsigned(mnFirstLine+mnVisLines) ) but that would then set mnFirstLine = static_cast<sal_uInt16>(nNewLine-mnVisLines+1); to 1 instead of leaving it at 0, which is probably not wanted.) Change-Id: I5b61cd25d52048e2cb2cf64f646d8ba9dd10adb7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88847 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 747205cd1f69..1662fcf8e9af 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -1008,7 +1008,7 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId ) { mnFirstLine = nNewLine; } - else if ( nNewLine > o3tl::make_unsigned(mnFirstLine+mnVisLines-1) ) + else if ( mnVisLines != 0 && nNewLine > o3tl::make_unsigned(mnFirstLine+mnVisLines-1) ) { mnFirstLine = static_cast<sal_uInt16>(nNewLine-mnVisLines+1); } @@ -2176,7 +2176,7 @@ void SfxThumbnailView::SelectItem( sal_uInt16 nItemId ) { mnFirstLine = nNewLine; } - else if ( nNewLine > o3tl::make_unsigned(mnFirstLine+mnVisLines-1) ) + else if ( mnVisLines != 0 && nNewLine > o3tl::make_unsigned(mnFirstLine+mnVisLines-1) ) { mnFirstLine = static_cast<sal_uInt16>(nNewLine-mnVisLines+1); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits