Skip to content

Commit

Permalink
Make String#replace to check equality before modifying flags.
Browse files Browse the repository at this point in the history
ref #3588
  • Loading branch information
matz committed Apr 5, 2017
1 parent a7b0ab3 commit 5e79bc9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,9 @@ str_replace(mrb_state *mrb, struct RString *s1, struct RString *s2)
long len;

check_frozen(mrb, s1);
if (s1 == s2) return mrb_obj_value(s1);
s1->flags &= ~MRB_STR_NO_UTF;
s1->flags |= s2->flags&MRB_STR_NO_UTF;
if (s1 == s2) return mrb_obj_value(s1);
len = RSTR_LEN(s2);
if (RSTR_SHARED_P(s1)) {
str_decref(mrb, s1->as.heap.aux.shared);
Expand Down

0 comments on commit 5e79bc9

Please sign in to comment.