diff options
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -10136,6 +10136,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc) 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; @@ -10243,7 +10244,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; } @@ -10251,6 +10253,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(); @@ -10259,10 +10262,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++; @@ -10288,6 +10293,8 @@ intern_str(VALUE str) if (m[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)); |