summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2019-04-07 22:43:01 -0700
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-04-08 10:29:59 +0200
commit7f37bfa25a16bc66af4c236850503de1d0fb8336 (patch)
treeafc1fc8d430cf06ebbb5ff949c593439ca776c08
parent5219a2822261350509ac83ed1c35db16732e15bf (diff)
Fix out-of-bounds error when adding a comment
The error is related to tdf#50916 and since commit 7282014e362a1529a36c88eb308df8ed359c2cfa it's necessary to retrieve the EndCol via ScTable::ClampToAllocatedColumns() otherwise this error occurs: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/debug/vector:417: Error: attempt to subscript container with out-of-bounds index 64, but container only holds 64 elements. Objects involved in the operation: sequence "this" @ 0x0x555556b28340 { type = std::__debug::vector<std::unique_ptr<ScColumn, std::default_delete<ScColumn> >, std::allocator<std::unique_ptr<ScColumn, std::default_delete<ScColumn> > > >; } The backtrace shows where the error occurs 0 0x00007ffff7b0ed7f in raise () at /usr/lib/libc.so.6 1 0x00007ffff7af9672 in abort () at /usr/lib/libc.so.6 2 0x00007ffff79a16c6 in __gnu_debug::_Error_formatter::_M_error() const (this=0x7fffdf156928 <__gnu_debug::_Error_formatter::_M_at(char const*, unsigned int)::__formatter>) at /build/gcc/src/gcc/libstdc++-v3/src/c++11/debug.cc:1069 3 0x00007fffdcd43fb3 in std::__debug::vector<std::unique_ptr<ScColumn, std::default_delete<ScColumn> >, std::allocator<std::unique_ptr<ScColumn, std::default_delete<ScColumn> > > >::operator[](unsigned long) (this=0x555556b28340, __n=64) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/debug/vector:417 4 0x00007fffdce75f5d in ScColContainer::operator[](unsigned long) (this=0x555556b28340, nIndex=64) at sc/inc/colcontainer.hxx:44 5 0x00007fffdcfb45f1 in ScDocument::HasColNotes(short, short) const (this=0x555556b1f9a0, nCol=64, nTab=0) at sc/source/core/data/document.cxx:6563 6 0x00007fffdd2b5473 in ScTable::GetAllNoteCaptionsState(ScRange const&, std::__debug::vector<sc::NoteEntry, std::allocator<sc::NoteEntry> >&) (this=0x555556b28340, rRange=..., rNotes=std::__debug::vector of length 2, capacity 2 = {...}) at sc/source/core/data/table2.cxx:1668 7 0x00007fffdcfb4d85 in ScDocument::GetAllNoteCaptionsState(ScRangeList const&) (this=0x555556b1f9a0, rRanges=...) at sc/source/core/data/document.cxx:6662 8 0x00007fffde20449e in ScCellShell::GetState(SfxItemSet&) (this=0x555556c99fc0, rSet=...) at sc/source/ui/view/cellsh.cxx:1121 9 0x00007fffde200fb8 in SfxStubScCellShellGetState(SfxShell*, SfxItemSet&) (pShell=0x555556c99fc0, rSet=...) at workdir/SdiTarget/sc/sdi/scslots.hxx:7286 Change-Id: I568546cd7a3de510625c6c5d189d84f5f0a7bdb2 Reviewed-on: https://gerrit.libreoffice.org/70399 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
-rw-r--r--sc/source/core/data/table2.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 9839763e8a14..2a288c46423f 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1656,7 +1656,9 @@ CommentCaptionState ScTable::GetAllNoteCaptionsState(const ScRange& rRange, std:
bool bIsFirstNoteShownState = true; // because of error: -Werror=maybe-uninitialized
bool bFirstControl = true;
- for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
+ ScTable* pTab = pDocument->FetchTable(nTab);
+ const SCCOL nEndCol = pTab->ClampToAllocatedColumns(rRange.aEnd.Col());
+ for (SCCOL nCol = rRange.aStart.Col(); nCol <= nEndCol; ++nCol)
{
if (bFirstControl && pDocument->HasColNotes(nCol, nTab)) // detect status of first note caption
{