From fd7583acc0adcce2fa63d21755091ddb3077aa14 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 1 Jul 2023 11:06:22 -0700 Subject: Fixed potential memory corruption/race condition. --- src/tests/utf.cpp | 1 + src/unstable/utfstring.cpp | 8 ++++++++ src/unstable/utfstring.h | 1 + 3 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/tests/utf.cpp b/src/tests/utf.cpp index 40d4194..ef7297d 100644 --- a/src/tests/utf.cpp +++ b/src/tests/utf.cpp @@ -7,6 +7,7 @@ using namespace Bu; int main() { + sio << "Code: " << Bu::__calcHashCode( Bu::UtfString() ) << sio.nl; sio << "Code: " << Bu::__calcHashCode( Bu::UtfString("Hello there") ) << sio.nl; diff --git a/src/unstable/utfstring.cpp b/src/unstable/utfstring.cpp index 9b712c9..be03c6e 100644 --- a/src/unstable/utfstring.cpp +++ b/src/unstable/utfstring.cpp @@ -47,6 +47,14 @@ Bu::UtfString::UtfString( const char *sInput, Encoding eEnc ) set( Bu::Blob(sInput), eEnc ); } +Bu::UtfString::UtfString( const UtfString &rSrc ) : + aData( rSrc.aData.clone() ), + iRawLen( rSrc.iRawLen ), + iCharLen( rSrc.iCharLen ) +{ + +} + Bu::UtfString::~UtfString() { } diff --git a/src/unstable/utfstring.h b/src/unstable/utfstring.h index 5355f3e..e36c2dd 100644 --- a/src/unstable/utfstring.h +++ b/src/unstable/utfstring.h @@ -74,6 +74,7 @@ namespace Bu UtfString( const Bu::String &sInput, Encoding eEnc=Utf8 ); UtfString( const Bu::Blob &sInput, Encoding eEnc=Utf8 ); UtfString( const char *sInput, Encoding eEnc=Utf8 ); + UtfString( const UtfString &rSrc ); virtual ~UtfString(); class iterator -- cgit v1.2.3