sw/qa/core/edit/edit.cxx |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

New commits:
commit 4f84b4c23f4634cd5b9f24a2fd61712dc85306a6
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri May 19 09:35:09 2023 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri May 19 11:19:55 2023 +0200

    CppunitTest_sw_core_edit: add test for the FnChgToEnEmDash() fix
    
    Fails with commit 971c9945825db02a4809538d26fff3ae77d16866 (Fix
    "AddressSanitizer: heap-use-after-free", 2023-05-18) reverted in an ASan
    build.
    
    Change-Id: Ie87039c2c46abaf2f73cb1bbad48d2d1f7e59392
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151991
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/core/edit/edit.cxx b/sw/qa/core/edit/edit.cxx
index 84c05301075f..444887fbb0df 100644
--- a/sw/qa/core/edit/edit.cxx
+++ b/sw/qa/core/edit/edit.cxx
@@ -12,6 +12,7 @@
 #include <docsh.hxx>
 #include <view.hxx>
 #include <wrtsh.hxx>
+#include <unotxdoc.hxx>
 
 namespace
 {
@@ -42,6 +43,19 @@ CPPUNIT_TEST_FIXTURE(Test, testRedlineHidden)
     pWrtShell->SetAttrSet(aSet, SetAttrMode::DEFAULT, nullptr, true);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testAutocorrect)
+{
+    // Given an empty document:
+    createSwDoc();
+
+    // When typing a string, which contains a "-", then make sure no memory 
corruption happens when
+    // it gets auto-corrected to "–":
+    auto pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    // Without the accompanying fix in place, this test would have failed with 
a
+    // heap-use-after-free:
+    emulateTyping(*pTextDoc, u"But not now - with ");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */

Reply via email to