From b655734965155146290f3f3a9205243af11e42fb Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 13 May 2020 20:11:35 +0200 Subject: QString: fix an aliasing issue in remove(QString) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even in Qt 5, remove() can be passed an alias to *this. In Qt 6, with the advent of substring sharing, this will become even more pronounced. Use the same fix as was already used in QString::insert(). Pick-to: 5.15 Change-Id: I1a0d3d99fd7dff6e727661646d2cbfdc94df2682 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Edward Welbourne --- tests/auto/corelib/text/qstring/tst_qstring.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index cefcd4f2e5..38df331cc2 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -388,6 +388,7 @@ private slots: void remove_string(); void remove_regexp_data(); void remove_regexp(); + void remove_extra(); void swap(); void prepend_qstring() { prepend_impl(); } @@ -3028,6 +3029,15 @@ void tst_QString::remove_regexp() } } +void tst_QString::remove_extra() +{ + { + QString s = "The quick brown fox jumps over the lazy dog. " + "The lazy dog jumps over the quick brown fox."; + s.remove(s); + } +} + void tst_QString::toNum() { #if defined (Q_OS_WIN) && defined (Q_CC_MSVC) -- cgit v1.2.3