Skip to content

Commit

Permalink
Use memmove instead of memcpy
Browse files Browse the repository at this point in the history
Memmove is safer when pointers overlap, and they are.
  • Loading branch information
RobertBendun committed Dec 18, 2021
1 parent 23aadd5 commit 8a24c30
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/string_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ Value StringObject::lstrip_in_place(Env *env) {
if (first_char == 0)
return NilObject::the();

memcpy(&m_string[0], &m_string[0] + first_char, len - first_char);
memmove(&m_string[0], &m_string[0] + first_char, len - first_char);
m_string.truncate(len - first_char);
return this;
}
Expand Down

0 comments on commit 8a24c30

Please sign in to comment.