Skip to content

Commit df40f9f

Browse files
committed
kernel: fix string copying logic
1 parent 458a4fd commit df40f9f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/stringobj.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,8 @@ Obj CopyToStringRep(
12431243
copy = NEW_STRING(lenString);
12441244

12451245
if ( IS_STRING_REP(string) ) {
1246-
memcpy(ADDR_OBJ(copy), CONST_ADDR_OBJ(string), SIZE_OBJ(string));
1246+
memcpy(CHARS_STRING(copy), CONST_CHARS_STRING(string),
1247+
GET_LEN_STRING(string));
12471248
/* XXX no error checks? */
12481249
} else {
12491250
/* copy the string to the string representation */
@@ -1267,7 +1268,7 @@ Obj CopyToStringRep(
12671268
*/
12681269
Obj ImmutableString(Obj string)
12691270
{
1270-
if (!IS_STRING_REP(string) || !IS_MUTABLE_OBJ(string)) {
1271+
if (!IS_STRING_REP(string) || IS_MUTABLE_OBJ(string)) {
12711272
string = CopyToStringRep(string);
12721273
MakeImmutableString(string);
12731274
}

0 commit comments

Comments
 (0)