oox/source/export/drawingml.cxx |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 0151a5a2e9114375cd3256e3cca495b2347ebefb
Author:     Simon Chenery <simon_chen...@yahoo.com>
AuthorDate: Sat Apr 5 09:28:34 2025 +0200
Commit:     Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
CommitDate: Sat May 31 07:52:07 2025 +0200

    Check oox-drawingml-adj-names has delimiter to avoid std::out_of_range 
exception
    
    Skip line with warning if no tab delimiter found. This avoids a
    std::string_view.substr(-1) call, that throws an std::out_of_range
    exception.
    
    Change-Id: Ie35ea692ce3c2cbc8c21c01b0c488a6bb5eb5e32
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183741
    Tested-by: Jenkins
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 43a96c6af45f..fdb2d84629ec 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -4504,8 +4504,15 @@ static std::map< OString, std::vector<OString> > 
lcl_getAdjNames()
         sal_Int32 nIndex = 0;
         // Each line is in a "key      value" format: read the key, the rest 
is the value.
         OString aKey( o3tl::getToken(aLine, 0, '       ', nIndex) );
-        OString aValue( std::string_view(aLine).substr(nIndex) );
-        aRet[aKey].push_back(aValue);
+        if (nIndex >= 0)
+        {
+            OString aValue( std::string_view(aLine).substr(nIndex) );
+            aRet[aKey].push_back(aValue);
+        }
+        else
+        {
+            SAL_WARN("oox.shape", "skipping invalid line: " << 
std::string_view(aLine));
+        }
         bNotDone = aStream.ReadLine(aLine);
     }
     return aRet;

Reply via email to