diff options
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -1478,6 +1478,12 @@ rb_str_aref(VALUE str, VALUE indx) idx = FIX2LONG(indx); num_index: + if (idx < 0) { + idx = RSTRING(str)->len + idx; + } + if (idx < 0 || RSTRING(str)->len <= idx) { + return Qnil; + } return rb_str_substr(str, idx, 1); case T_REGEXP: |