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:
Peter Zhu 2020-09-01 06:01:32 -04:00 коммит произвёл GitHub
Родитель a137874e67
Коммит 21ad4075a7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 1 добавлений и 1 удалений

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: {