fix ubsan in SharedStringPool

with a slightly dodgy fix.

regression from
    commit 3581f1d71ae0d431ba28c0f3b7b263ff6212ce7b
    optimize SharedStringPool::purge() and fix tests

It's not ideal - we no longer have a way of purging uppercase keys that
are longer in use.
But that doesn't cost much memory, because we are sharing those strings.

We could potentially identify them with extra book-keeping in either
intern() or purge(), but since this class is performance-sensitive, best
just to sacrifice some space in the map.

Change-Id: I85a469448f5b36b1b6889da60280edd56bbcb083
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95432
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit 4aa6ae8ba911bd3420d3b74c085aa69d87339f4d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95426
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 6b44a96..2c266e4 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -392,10 +392,10 @@ void Test::testSharedStringPoolPurge()
    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), aPool.getCount());
    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aPool.getCountIgnoreCase());

    // Ditto...
    // Nothing changes, because the upper-string is still in the map
    pStr3.reset();
    aPool.purge();
    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aPool.getCount());
    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), aPool.getCount());
    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aPool.getCountIgnoreCase());

    // Again.
diff --git a/svl/source/misc/sharedstringpool.cxx b/svl/source/misc/sharedstringpool.cxx
index 2589808..d2d8900 100644
--- a/svl/source/misc/sharedstringpool.cxx
+++ b/svl/source/misc/sharedstringpool.cxx
@@ -60,7 +60,12 @@ SharedString SharedStringPool::intern( const OUString& rStr )
            // need to use the same underlying rtl_uString object so the
            // upper->upper detection in purge() works
            auto pData = insertResult.first->pData;
            mpImpl->maStrMap.insert_or_assign(mapIt, pData, pData);
            // This is dodgy, but necessary. I don't want to do a delete/insert because
            // this class is very performance sensitive. This does not violate the internals
            // the map because the new key points to something with the same hash and equality
            // as the old key.
            const_cast<OUString&>(mapIt->first) = *insertResult.first;
            mapIt->second = pData;
        }
        else
        {