diff options
author | Mike Buland <eichlan@xagasoft.com> | 2023-07-01 11:06:22 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2023-07-01 11:06:22 -0700 |
commit | fd7583acc0adcce2fa63d21755091ddb3077aa14 (patch) | |
tree | d2c7b019c4ff994b9347141a54a83cc8bffee667 | |
parent | a655bb28194bcea9efc2550d9c41c422c05ce762 (diff) | |
download | libbu++-fd7583acc0adcce2fa63d21755091ddb3077aa14.tar.gz libbu++-fd7583acc0adcce2fa63d21755091ddb3077aa14.tar.bz2 libbu++-fd7583acc0adcce2fa63d21755091ddb3077aa14.tar.xz libbu++-fd7583acc0adcce2fa63d21755091ddb3077aa14.zip |
Fixed potential memory corruption/race condition.
Diffstat (limited to '')
-rw-r--r-- | default.bld | 5 | ||||
-rw-r--r-- | src/tests/utf.cpp | 1 | ||||
-rw-r--r-- | src/unstable/utfstring.cpp | 8 | ||||
-rw-r--r-- | src/unstable/utfstring.h | 1 |
4 files changed, 15 insertions, 0 deletions
diff --git a/default.bld b/default.bld index b30e374..8f21f6c 100644 --- a/default.bld +++ b/default.bld | |||
@@ -14,6 +14,11 @@ | |||
14 | include "gensigs.bld"; | 14 | include "gensigs.bld"; |
15 | 15 | ||
16 | CXXFLAGS += "-ggdb -W -Wall -I."; | 16 | CXXFLAGS += "-ggdb -W -Wall -I."; |
17 | |||
18 | // Deep memory checks | ||
19 | // CXXFLAGS += "-fsanitize=address -fno-omit-frame-pointer"; | ||
20 | // LDFLAGS += "-fsanitize=address -fno-omit-frame-pointer"; | ||
21 | |||
17 | //CXXFLAGS += "-pg"; | 22 | //CXXFLAGS += "-pg"; |
18 | //LDFLAGS += "-pg"; | 23 | //LDFLAGS += "-pg"; |
19 | 24 | ||
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; | |||
7 | 7 | ||
8 | int main() | 8 | int main() |
9 | { | 9 | { |
10 | sio << "Code: " << Bu::__calcHashCode( Bu::UtfString() ) << sio.nl; | ||
10 | sio << "Code: " << Bu::__calcHashCode( Bu::UtfString("Hello there") ) | 11 | sio << "Code: " << Bu::__calcHashCode( Bu::UtfString("Hello there") ) |
11 | << sio.nl; | 12 | << sio.nl; |
12 | 13 | ||
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 ) | |||
47 | set( Bu::Blob(sInput), eEnc ); | 47 | set( Bu::Blob(sInput), eEnc ); |
48 | } | 48 | } |
49 | 49 | ||
50 | Bu::UtfString::UtfString( const UtfString &rSrc ) : | ||
51 | aData( rSrc.aData.clone() ), | ||
52 | iRawLen( rSrc.iRawLen ), | ||
53 | iCharLen( rSrc.iCharLen ) | ||
54 | { | ||
55 | |||
56 | } | ||
57 | |||
50 | Bu::UtfString::~UtfString() | 58 | Bu::UtfString::~UtfString() |
51 | { | 59 | { |
52 | } | 60 | } |
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 | |||
74 | UtfString( const Bu::String &sInput, Encoding eEnc=Utf8 ); | 74 | UtfString( const Bu::String &sInput, Encoding eEnc=Utf8 ); |
75 | UtfString( const Bu::Blob &sInput, Encoding eEnc=Utf8 ); | 75 | UtfString( const Bu::Blob &sInput, Encoding eEnc=Utf8 ); |
76 | UtfString( const char *sInput, Encoding eEnc=Utf8 ); | 76 | UtfString( const char *sInput, Encoding eEnc=Utf8 ); |
77 | UtfString( const UtfString &rSrc ); | ||
77 | virtual ~UtfString(); | 78 | virtual ~UtfString(); |
78 | 79 | ||
79 | class iterator | 80 | class iterator |