diff options
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -10367,6 +10367,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a if (m >= e || (*m != '_' && !rb_enc_isalpha(*m, enc) && ISASCII(*m))) return -1; while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc); + if (m >= e) break; switch (*m) { case '!': case '?': if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1; @@ -10484,7 +10485,8 @@ intern_str(VALUE str) enc = rb_enc_get(str); symenc = enc; - if (rb_cString && !rb_enc_asciicompat(enc)) { + if (!len || (rb_cString && !rb_enc_asciicompat(enc))) { + junk: id = ID_JUNK; goto new_id; } @@ -10492,6 +10494,7 @@ intern_str(VALUE str) id = 0; switch (*m) { case '$': + if (len < 2) goto junk; id |= ID_GLOBAL; if ((mb = is_special_global_name(++m, e, enc)) != 0) { if (!--mb) symenc = rb_usascii_encoding(); @@ -10500,10 +10503,12 @@ intern_str(VALUE str) break; case '@': if (m[1] == '@') { + if (len < 3) goto junk; m++; id |= ID_CLASS; } else { + if (len < 2) goto junk; id |= ID_INSTANCE; } m++; @@ -10530,6 +10535,8 @@ intern_str(VALUE str) } if (name[last] == '=') { /* attribute assignment */ + if (!rb_enc_symname2_p(name, last, enc)) + goto junk; id = rb_intern3(name, last, enc); if (id > tLAST_OP_ID && !is_attrset_id(id)) { enc = rb_enc_get(rb_id2str(id)); |