Kaydet (Commit) 7f37bfa2 authored tarafından Jens Carl's avatar Jens Carl Kaydeden (comit) Noel Grandin

Fix out-of-bounds error when adding a comment

The error is related to tdf#50916 and since commit
7282014e 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/70399Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: 's avatarBartosz Kosiorek <gang65@poczta.onet.pl>
üst 5219a282
......@@ -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
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment