sw/source/core/text/txtfrm.cxx |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 25d50f08a27ee28698226a44db9c74a66a260754
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Jul 11 11:51:45 2023 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jul 11 22:00:21 2023 +0200

    sw layout xml dump: don't crash when text frame length is -1
    
    Of course this should not happen once the layout settles, but it can
    happen in the middle of debugging and the dumper itself should never
    result in an assertion failure.
    
    Change-Id: I425b8758f6f6f948752d40d081c8ed61855f9bcd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154294
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 821c22f528cd..7f1c17691ccf 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -843,10 +843,13 @@ void SwTextFrame::dumpAsXml(xmlTextWriterPtr writer) const
     {
         nTextLength = static_cast<sal_Int32>(pTextFrameFollow->GetOffset() - 
GetOffset());
     }
-    OString aText8
-        = OUStringToOString(aText.subView(nTextOffset, nTextLength), 
RTL_TEXTENCODING_UTF8);
-    (void)xmlTextWriterWriteString( writer,
-            reinterpret_cast<const xmlChar *>(aText8.getStr(  )) );
+    if (nTextLength > 0)
+    {
+        OString aText8
+            = OUStringToOString(aText.subView(nTextOffset, nTextLength), 
RTL_TEXTENCODING_UTF8);
+        (void)xmlTextWriterWriteString( writer,
+                reinterpret_cast<const xmlChar *>(aText8.getStr(  )) );
+    }
     if (const SwParaPortion* pPara = GetPara())
     {
         (void)xmlTextWriterStartElement(writer, BAD_CAST("SwParaPortion"));

Reply via email to