Skip to content

Commit 0c6f04f

Browse files
author
Charles PIGNEROL
committed
Version 6.14.1. UnicodeString fix, calls to memcpy, highlighted by GNU and LLVM sanitizer when the string is null.
1 parent af22f0d commit 0c6f04f

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

cmake/version.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
set (TK_UTIL_MAJOR_VERSION "6")
66
set (TK_UTIL_MINOR_VERSION "14")
7-
set (TK_UTIL_RELEASE_VERSION "0")
7+
set (TK_UTIL_RELEASE_VERSION "1")
88
set (TK_UTIL_VERSION ${TK_UTIL_MAJOR_VERSION}.${TK_UTIL_MINOR_VERSION}.${TK_UTIL_RELEASE_VERSION})
99

1010
set (TK_UTIL_SCRIPTING_MAJOR_VERSION ${TK_UTIL_MAJOR_VERSION})

src/TkUtil/UnicodeString.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ bool UnicodeString::operator == (const UnicodeString& toCompare) const
419419
if (length ( ) != toCompare.length ( ))
420420
return false;
421421

422-
return 0 == memcmp (unicode ( ), toCompare.unicode ( ),
423-
length ( ) * sizeof (WChar_t));
422+
return 0 == memcmp (unicode ( ), toCompare.unicode ( ), length ( ) * sizeof (WChar_t));
424423
} // UnicodeString::operator ==
425424

426425

@@ -889,7 +888,8 @@ void UnicodeString::copy (const UnicodeString& str)
889888
_length = str.length ( );
890889
_string = new WChar_t [_length + 1];
891890
CHECK_NULL_PTR_ERROR (_string)
892-
memcpy (_string, str.unicode ( ), _length * sizeof (WChar_t));
891+
if (0 != unicode ( )) // v 6.14.1
892+
memcpy (_string, str.unicode ( ), _length * sizeof (WChar_t));
893893
_string [_length] = 0;
894894
} // UnicodeString::copy
895895

@@ -903,7 +903,8 @@ void UnicodeString::copy (const WChar_t* str)
903903
_length = stringLength (str);
904904
_string = new WChar_t [_length + 1];
905905
CHECK_NULL_PTR_ERROR (_string)
906-
memcpy (_string, str, _length * sizeof (WChar_t));
906+
if (0 != unicode ( )) // v 6.14.1
907+
memcpy (_string, str, _length * sizeof (WChar_t));
907908
_string [_length] = 0;
908909
} // UnicodeString::copy
909910

@@ -942,9 +943,10 @@ UnicodeString operator + (const UnicodeString& us1, const UnicodeString& us2)
942943
const size_t length = us1.length ( ) + us2.length ( );
943944
WChar_t* str = new WChar_t [length + 1];
944945
CHECK_NULL_PTR_ERROR (str)
945-
memcpy (str, us1.unicode ( ), us1.length ( ) * sizeof (WChar_t));
946-
memcpy (str + us1.length ( ), us2.unicode ( ),
947-
us2.length ( ) * sizeof (WChar_t));
946+
if (0 != us1.unicode ( )) // v 6.14.1
947+
memcpy (str, us1.unicode ( ), us1.length ( ) * sizeof (WChar_t));
948+
if (0 != us2.unicode ( )) // v 6.14.1
949+
memcpy (str + us1.length ( ), us2.unicode ( ), us2.length ( ) * sizeof (WChar_t));
948950
str [length] = 0;
949951

950952
UnicodeString us (str);

versions.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 6.14.1 : 20/02/26
2+
=================
3+
4+
Correctif UnicodeString, appels à memcpy, mis en évidence par GNU et LLVM sanitizer lorsque la chaîne est nulle.
5+
6+
17
Version 6.14.0 : 07/11/25
28
=================
39

0 commit comments

Comments
 (0)