i18npool/source/indexentry/indexentrysupplier_default.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 48653e1edbc72c2a45e8861a837e6233cad1fbba
Author: Stephan Bergmann <sberg...@redhat.com>
Date:   Thu Jan 25 11:31:45 2018 +0100

    Fix Index::getIndexWeight for empty input
    
    ...which triggers the assertion `index >= 0 && 
static_cast<sal_uInt32>(index) <
    static_cast<sal_uInt32>(getLength())' in rtl::OUString::operator[] at
    include/rtl/ustring.hxx:669 (see below for a reproducer).
    
    I am not sure whether the case of `startPos == rIndexEntry.getLength()` 
should
    really go into the following for loop inspecting `tables`, with a somewhat
    random `code` of U+0000 (or some other value even?), or should rather be 
handled
    explicitly in some other way.
    
    Reproducer in an empty Writer document: "Insert - Table of Contents and 
Index -
    Bibliography Entry...": "Insert Bibliography Entry" dialog: "ARJ00", 
"Insert",
    "AVV00", "Insert", "Close"; "Insert - Table of Contents and Index - Table of
    Contents, Index or Bibliography...": "Table of Contents, Index or 
Bibliography"
    dialog: "Type - Type and Title - Type: Bibliography", "Entries - Sort by -
    Content", "Entries - Sort Keys - 1: Address", "OK": assert fires
    
    Change-Id: I2c9fad2c37bfa7a3509c197e678311fb45cb991a
    Reviewed-on: https://gerrit.libreoffice.org/48564
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Eike Rathke <er...@redhat.com>
    (cherry picked from commit ad9d70e73394b1d0d2c1e1e4584c8bc6f3a5d8b3)
    Reviewed-on: https://gerrit.libreoffice.org/48635

diff --git a/i18npool/source/indexentry/indexentrysupplier_default.cxx 
b/i18npool/source/indexentry/indexentrysupplier_default.cxx
index bcd7b2ab6d7c..af86b94c1ad9 100644
--- a/i18npool/source/indexentry/indexentrysupplier_default.cxx
+++ b/i18npool/source/indexentry/indexentrysupplier_default.cxx
@@ -138,7 +138,7 @@ sal_Int16 Index::getIndexWeight(const OUString& rIndexEntry)
                 return mkeys[i];
         }
     }
-    sal_Unicode code = rIndexEntry[startPos];
+    sal_Unicode code = startPos < rIndexEntry.getLength() ? 
rIndexEntry[startPos] : 0;
     for (sal_Int16 i = 0; i < table_count; i++) {
         if (tables[i].start <= code && code <= tables[i].end)
             return tables[i].table[code-tables[i].start];
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to