Fix cast from const by accessing string data directly (#8354)
authorrubenwardy <rw@rubenwardy.com>
Tue, 12 Mar 2019 07:58:02 +0000 (07:58 +0000)
committerrubenwardy <rw@rubenwardy.com>
Tue, 12 Mar 2019 20:25:55 +0000 (20:25 +0000)
Fixes #8327

src/irrlicht_changes/irrUString.h

index fce49e7177d3397c1c47dbaaeb65e54a3cb05bbb..b628c092c28b5a2371d65910ec81f126a498626a 100644 (file)
@@ -2916,13 +2916,13 @@ public:
                                ret[0] = unicode::BOM;
                        else if (endian == unicode::EUTFEE_LITTLE)
                        {
-                               uchar8_t* ptr8 = reinterpret_cast<uchar8_t*>(ret.c_str());
+                               uchar8_t* ptr8 = reinterpret_cast<uchar8_t*>(&ret[0]);
                                *ptr8++ = unicode::BOM_ENCODE_UTF16_LE[0];
                                *ptr8 = unicode::BOM_ENCODE_UTF16_LE[1];
                        }
                        else
                        {
-                               uchar8_t* ptr8 = reinterpret_cast<uchar8_t*>(ret.c_str());
+                               uchar8_t* ptr8 = reinterpret_cast<uchar8_t*>(&ret[0]);
                                *ptr8++ = unicode::BOM_ENCODE_UTF16_BE[0];
                                *ptr8 = unicode::BOM_ENCODE_UTF16_BE[1];
                        }