diff options
author | Peter Zhu <peter@peterzhu.ca> | 2020-09-01 06:01:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-01 19:01:32 +0900 |
commit | 21ad4075a71f302474a78dc744149ac8ce2ff0ec (patch) | |
tree | d4889e5d25b106d9a67a15ac65254d89d5bc32fb /gc.c | |
parent | a137874e67b0b3f815be3ba322ed8925860bc673 (diff) | |
download | ruby-21ad4075a71f302474a78dc744149ac8ce2ff0ec.tar.gz |
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.
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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: { |