Avoid unsigned wrap-around when nVisibleViewCount is zero

Desktop / LibreOffice - Stephan Bergmann [redhat.com] - 15 August 2018 12:35 EDT

...(and some more improvements to that code, like dropping the unnecessary casting to sal_uInt16) as Clang's new -fsanitize=implicit-conversion flags during CppunitTest_dbaccess_dialog_save:

> svtools/source/contnr/svimpbox.cxx:1317:26: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'sal_uInt16' (aka 'unsigned short') changed the value to 65535 (16-bit, unsigned) > #0 in SvImpLBox::FillView() at svtools/source/contnr/svimpbox.cxx:1317:26 (instdir/program/libsvtlo.so +0x15e6edb) > #1 in SvImpLBox::UpdateAll(bool) at svtools/source/contnr/svimpbox.cxx:697:5 (instdir/program/libsvtlo.so +0x15e5151) > #2 in SvImpLBox::Resize() at svtools/source/contnr/svimpbox.cxx:1299:9 (instdir/program/libsvtlo.so +0x1602c31) > #3 in SvTreeListBox::Resize() at svtools/source/contnr/treelistbox.cxx:1427:12 (instdir/program/libsvtlo.so +0x17282ee) > #4 in vcl::Window::ImplCallResize() at vcl/source/window/event.cxx:523:5 (instdir/program/libvcllo.so +0x3196951) > #5 in vcl::Window::ImplPosSizeWindow(long, long, long, long, PosSizeFlags) at vcl/source/window/window.cxx:1603:17 (instdir/program/libvcllo.so +0x374c602) > #6 in vcl::Window::setPosSizePixel(long, long, long, long, PosSizeFlags) at vcl/source/window/window.cxx:2828:18 (instdir/program/libvcllo.so +0x377e616) > #7 in vcl::Window::SetPosSizePixel(Point const&, Size const&) at vcl/source/window/window2.cxx:1300:5 (instdir/program/libvcllo.so +0x36deba1) > #8 in dbaui::OAppDetailPageHelper::Resize() at dbaccess/source/ui/app/AppDetailPageHelper.cxx:928:18 (instdir/program/libdbulo.so +0x1733a91) > #9 in dbaui::OAppDetailPageHelper::switchPreview(dbaui::PreviewMode, bool) at dbaccess/source/ui/app/AppDetailPageHelper.cxx:988:9 (instdir/program/libdbulo.so +0x172ce0e) > #10 in dbaui::OAppDetailPageHelper::setDetailPage(vcl::Window*) at dbaccess/source/ui/app/AppDetailPageHelper.cxx:657:5 (instdir/program/libdbulo.so +0x1725e81) > #11 in dbaui::OAppDetailPageHelper::createPage(dbaui::ElementType, com::sun::star::uno::Reference const&) at dbaccess/source/ui/app/AppDetailPageHelper.cxx:637:9 (instdir/program/libdbulo.so +0x172796e) > #12 in dbaui::OApplicationDetailView::impl_createPage(dbaui::ElementType, com::sun::star::uno::Reference const&, com::sun::star::uno::Reference const&) at dbaccess/source/ui/app/AppDetailView.cxx:647:27 (instdir/program/libdbulo.so +0x1780e95) > #13 in dbaui::OApplicationDetailView::createPage(dbaui::ElementType, com::sun::star::uno::Reference const&) at dbaccess/source/ui/app/AppDetailView.cxx:626:5 (instdir/program/libdbulo.so +0x17810c9) > #14 in dbaui::OApplicationController::onContainerSelect(dbaui::ElementType) at dbaccess/source/ui/app/AppController.cxx:1695:46 (instdir/program/libdbulo.so +0x161a37e) > #15 in dbaui::OApplicationSwapWindow::onContainerSelected(dbaui::ElementType) at dbaccess/source/ui/app/AppSwapWindow.cxx:139:53 (instdir/program/libdbulo.so +0x17c5310) > #16 in dbaui::OApplicationSwapWindow::OnContainerSelectHdl(SvtIconChoiceCtrl*) at dbaccess/source/ui/app/AppSwapWindow.cxx:157:9 (instdir/program/libdbulo.so +0x17c5908) > #17 in dbaui::OApplicationSwapWindow::LinkStubOnContainerSelectHdl(void*, SvtIconChoiceCtrl*) at dbaccess/source/ui/app/AppSwapWindow.cxx:150:1 (instdir/program/libdbulo.so +0x17c0a90) > #18 in Link::Call(SvtIconChoiceCtrl*) const at include/tools/link.hxx:84:45 (instdir/program/libsvtlo.so +0x15a0863) > #19 in SvtIconChoiceCtrl::ClickIcon() at svtools/source/contnr/ivctrl.cxx:276:20 (instdir/program/libsvtlo.so +0x159c680) > #20 in SvxIconChoiceCtrl_Impl::CallSelectHandler() at svtools/source/contnr/imivctl1.cxx:3386:16 (instdir/program/libsvtlo.so +0x15194ef) > #21 in SvxIconChoiceCtrl_Impl::SelectEntry(SvxIconChoiceCtrlEntry*, bool, bool) at svtools/source/contnr/imivctl1.cxx:384:9 (instdir/program/libsvtlo.so +0x1518f4d) > #22 in SvxIconChoiceCtrl_Impl::SetCursor(SvxIconChoiceCtrlEntry*) at svtools/source/contnr/imivctl1.cxx:2001:13 (instdir/program/libsvtlo.so +0x1519c69) > #23 in SvtIconChoiceCtrl::SetCursor(SvxIconChoiceCtrlEntry*) at svtools/source/contnr/ivctrl.cxx:310:13 (instdir/program/libsvtlo.so +0x159d140) > #24 in dbaui::OApplicationSwapWindow::selectContainer(dbaui::ElementType) at dbaccess/source/ui/app/AppSwapWindow.cxx:179:25 (instdir/program/libdbulo.so +0x17c6415) > #25 in dbaui::OApplicationView::selectContainer(dbaui::ElementType) at dbaccess/source/ui/app/AppView.cxx:441:17 (instdir/program/libdbulo.so +0x17e2df6) > #26 in dbaui::OApplicationController::OnSelectContainer(void*) at dbaccess/source/ui/app/AppController.cxx:1873:25 (instdir/program/libdbulo.so +0x161ef9d) > #27 in dbaui::OApplicationController::LinkStubOnSelectContainer(void*, void*) at dbaccess/source/ui/app/AppController.cxx:1869:1 (instdir/program/libdbulo.so +0x15e6660) > #28 in Link::Call(void*) const at include/tools/link.hxx:84:45 (instdir/program/libdbulo.so +0x1814063) > #29 in dbaui::OAsynchronousLink::OnAsyncCall(void*) at dbaccess/source/ui/browser/AsynchronousLink.cxx:80:16 (instdir/program/libdbulo.so +0x1813e7b) > #30 in dbaui::OAsynchronousLink::LinkStubOnAsyncCall(void*, void*) at dbaccess/source/ui/browser/AsynchronousLink.cxx:67:1 (instdir/program/libdbulo.so +0x1813b7e) > #31 in Link::Call(void*) const at include/tools/link.hxx:84:45 (instdir/program/libvcllo.so +0x3829953) > #32 in ImplHandleUserEvent(ImplSVEvent*) at vcl/source/window/winproc.cxx:1929:30 (instdir/program/libvcllo.so +0x381d774) > #33 in ImplWindowFrameProc(vcl::Window*, SalEvent, void const*) at vcl/source/window/winproc.cxx:2482:13 (instdir/program/libvcllo.so +0x380e97f) > #34 in SalFrame::CallCallback(SalEvent, void const*) const at vcl/inc/salframe.hxx:280:29 (instdir/program/libvcllo.so +0x53690fa) > #35 in SvpSalInstance::ProcessEvent(SalUserEventList::SalUserEvent) at vcl/headless/svpinst.cxx:280:22 (instdir/program/libvcllo.so +0x53adf67) > #36 in SalUserEventList::DispatchUserEvents(bool) at vcl/source/app/salusereventlist.cxx:109:17 (instdir/program/libvcllo.so +0x4bdc0c3) > #37 in SvpSalInstance::DoYield(bool, bool) at vcl/headless/svpinst.cxx:414:19 (instdir/program/libvcllo.so +0x53b1464) > #38 in ImplYield(bool, bool) at vcl/source/app/svapp.cxx:471:48 (instdir/program/libvcllo.so +0x4d4d08a) > #39 in Application::Reschedule(bool) at vcl/source/app/svapp.cxx:488:12 (instdir/program/libvcllo.so +0x4d35650) > #40 in framework::StatusIndicatorFactory::impl_reschedule(bool) at framework/source/helper/statusindicatorfactory.cxx:523:13 (instdir/program/libfwklo.so +0xe3c97f) > #41 in framework::StatusIndicatorFactory::start(com::sun::star::uno::Reference const&, rtl::OUString const&, int) at framework/source/helper/statusindicatorfactory.cxx:143:5 (instdir/program/libfwklo.so +0xe3a336) > #42 in framework::StatusIndicator::start(rtl::OUString const&, int) at framework/source/helper/statusindicator.cxx:51:19 (instdir/program/libfwklo.so +0xe334f8) > #43 in dbaccess::(anonymous namespace)::lcl_triggerStatusIndicator_throw(comphelper::NamedValueCollection const&, dbaccess::DocumentGuard&, bool) at dbaccess/source/core/dataaccess/databasedocument.cxx:270:35 (instdir/program/libdbalo.so +0x114b3b3) > #44 in dbaccess::ODatabaseDocument::impl_storeToStorage_throw(com::sun::star::uno::Reference const&, com::sun::star::uno::Sequence const&, dbaccess::DocumentGuard&) const at dbaccess/source/core/dataaccess/databasedocument.cxx:1219:9 (instdir/program/libdbalo.so +0x1138ffd) > #45 in dbaccess::ODatabaseDocument::impl_storeAs_throw(rtl::OUString const&, comphelper::NamedValueCollection const&, dbaccess::ODatabaseDocument::StoreType, dbaccess::DocumentGuard&) at dbaccess/source/core/dataaccess/databasedocument.cxx:1064:9 (instdir/program/libdbalo.so +0x11484f3) > #46 in dbaccess::ODatabaseDocument::store() at dbaccess/source/core/dataaccess/databasedocument.cxx:966:9 (instdir/program/libdbalo.so +0x11457bc) > #47 in DialogSaveTest::test() at dbaccess/qa/extras/dialog-save.cxx:98:23 (workdir/LinkTarget/CppunitTest/libtest_dbaccess_dialog_save.so +0x1fb5a)

Change-Id: I7be2e468f9101d247f6247eb5e63393d711c0de2 Reviewed-on: https://gerrit.libreoffice.org/59067

2c16b803b681 Avoid unsigned wrap-around when nVisibleViewCount is zero
svtools/source/contnr/svimpbox.cxx | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

Upstream: cgit.freedesktop.org


  • Share