mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Don't read past the end of the Ruby string
Ruby strings don't always have a null terminator, so we can't use it as a regular C string. By reading only the first len bytes of the Ruby string, we won't read past the end of the Ruby string.
This commit is contained in:
parent
a137874e67
commit
21ad4075a7
Notes:
git
2020-09-01 19:02:04 +09:00
Merged: https://github.com/ruby/ruby/pull/3487 Merged-By: nobu <nobu@ruby-lang.org>
1 changed files with 1 additions and 1 deletions
2
gc.c
2
gc.c
|
@ -11667,7 +11667,7 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
|
|||
}
|
||||
break;
|
||||
case T_STRING: {
|
||||
APPENDF((BUFF_ARGS, "%s", RSTRING_PTR(obj)));
|
||||
APPENDF((BUFF_ARGS, "%.*s", (int)RSTRING_LEN(obj), RSTRING_PTR(obj)));
|
||||
break;
|
||||
}
|
||||
case T_MOVED: {
|
||||
|
|
Loading…
Add table
Reference in a new issue