Skip to content

Conversation

@nobu
Copy link
Member

@nobu nobu commented Jan 16, 2024

@nobu nobu merged commit 8230552 into ruby:master Jan 16, 2024
@nobu nobu deleted the coderange_after_overwrite branch January 16, 2024 15:06
kou pushed a commit that referenced this pull request Jan 18, 2024
Followup of #79

`rb_str_resize()` was changed by ruby/ruby@b0b9f72  .

```c
rb_str_resize(string, shorter) // clear ENC_CODERANGE in some case
rb_str_resize(string, longer) // does not clear ENC_CODERANGE anymore
```

```c
// rb_str_resize in string.c
if (slen > len && ENC_CODERANGE(str) != ENC_CODERANGE_7BIT) {
  ENC_CODERANGE_CLEAR(str);
}
```

I think this change is based on an assumption that appending null bytes
will not change flag `ascii_only?`.

`strio_extend()` will make the string longer if needed, and update the
flags correctly for appending null bytes.
Before `memmove()`, we need to `rb_str_modify()` because updated flags are not
updated for `memmove()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant