Skip to content

Commit

Permalink
Restore mstring strncpy's.
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsbers committed Nov 9, 2024
1 parent 3f2bc64 commit a8eb0bc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/mstring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ void MStringRef::create(const char* str, size_t len) {
if (len) {
alloc(len);
if (str) {
strncpy(fStr->fStr, str, len + 1);
strncpy(fStr->fStr, str, len);
fStr->fStr[len] = 0;
} else {
fStr->fStr[0]=0;
memset(fStr->fStr, 0, len + 1);
}
} else {
fStr = nullptr;
Expand All @@ -44,9 +45,9 @@ mstring::mstring(const char* str1, size_t len1, const char* str2, size_t len2):
{
if (fRef) {
if (len1)
strncpy(fRef->fStr, str1, len1 + 1);
strncpy(fRef->fStr, str1, len1);
if (len2)
strncpy(fRef->fStr + len1, str2, len2 + 1);
strncpy(fRef->fStr + len1, str2, len2);
fRef[fCount] = 0;
fRef.acquire();
}
Expand Down

0 comments on commit a8eb0bc

Please sign in to comment.