Project

General

Profile

Bug #16008 ยป ripper-hash-pattern-on_label-16008.patch

jeremyevans0 (Jeremy Evans), 10/08/2019 04:37 PM

View differences:

parse.y
for (i = 0; i < len; i++) {
VALUE key, a1, a2, a3;
a1 = RARRAY_AREF(ary, i);
if (!(RB_TYPE_P(a1, T_ARRAY) && RARRAY_LEN(a1) == 2)) goto error;
if (!(RB_TYPE_P(a1, T_ARRAY) && RARRAY_LEN(a1) == 2)) goto invalid_format;
a2 = RARRAY_AREF(a1, 0);
if (!RB_TYPE_P(a2, T_ARRAY)) goto error;
if (!RB_TYPE_P(a2, T_ARRAY)) goto invalid_format;
switch (RARRAY_LEN(a2)) {
case 2: /* "key": */
a3 = RARRAY_AREF(a2, 1);
if (!(RB_TYPE_P(a3, T_ARRAY) && RARRAY_LEN(a3) == 3)) goto error;
if (!(RB_TYPE_P(a3, T_ARRAY) && RARRAY_LEN(a3) == 3)) goto invalid_format;
key = RARRAY_AREF(a3, 1);
break;
case 3: /* key: */
key = RARRAY_AREF(a2, 1);
break;
default:
goto error;
goto invalid_format;
}
if (!RB_TYPE_P(key, T_STRING)) goto error;
if (!RB_TYPE_P(key, T_STRING)) goto invalid_format;
if (st_lookup(tbl, (st_data_t)RSTRING_PTR(key), 0)) goto error;
st_insert(tbl, (st_data_t)RSTRING_PTR(key), (st_data_t)ary);
}
invalid_format:
st_free_table(tbl);
return ary;
    (1-1/1)