Project

General

Profile

Bug #10453 ยป num2chr-range-check-10453.patch

jeremyevans0 (Jeremy Evans), 08/12/2019 02:38 AM

View differences:

include/ruby/ruby.h
}
#define RB_ULONG2NUM(x) rb_ulong2num_inline(x)
static inline char
rb_num2char_inline(VALUE x)
{
if (RB_TYPE_P(x, RUBY_T_STRING) && (RSTRING_LEN(x)>=1))
return RSTRING_PTR(x)[0];
else
return (char)(NUM2INT(x) & 0xff);
}
#define RB_NUM2CHR(x) rb_num2char_inline(x)
#define RB_CHR2FIX(x) RB_INT2FIX((long)((x)&0xff))
......
RUBY_EXTERN VALUE rb_stdin, rb_stdout, rb_stderr;
static inline char
rb_num2char_inline(VALUE x)
{
if (RB_TYPE_P(x, RUBY_T_STRING) && (RSTRING_LEN(x)>=1))
return RSTRING_PTR(x)[0];
else {
unsigned int y = NUM2UINT(x);
if (y > 0xff)
rb_raise(rb_eRangeError, "value to large to convert to char: %u", y);
return (char)(y & 0xff);
}
}
static inline VALUE
rb_class_of(VALUE obj)
{
    (1-1/1)