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
805 805
    for (i = 0; i < len; i++) {
806 806
	VALUE key, a1, a2, a3;
807 807
	a1 = RARRAY_AREF(ary, i);
808
	if (!(RB_TYPE_P(a1, T_ARRAY) && RARRAY_LEN(a1) == 2)) goto error;
808
	if (!(RB_TYPE_P(a1, T_ARRAY) && RARRAY_LEN(a1) == 2)) goto invalid_format;
809 809
	a2 = RARRAY_AREF(a1, 0);
810
	if (!RB_TYPE_P(a2, T_ARRAY)) goto error;
810
	if (!RB_TYPE_P(a2, T_ARRAY)) goto invalid_format;
811 811
	switch (RARRAY_LEN(a2)) {
812 812
	  case 2: /* "key": */
813 813
	    a3 = RARRAY_AREF(a2, 1);
814
	    if (!(RB_TYPE_P(a3, T_ARRAY) && RARRAY_LEN(a3) == 3)) goto error;
814
	    if (!(RB_TYPE_P(a3, T_ARRAY) && RARRAY_LEN(a3) == 3)) goto invalid_format;
815 815
	    key = RARRAY_AREF(a3, 1);
816 816
	    break;
817 817
	  case 3: /* key: */
818 818
	    key = RARRAY_AREF(a2, 1);
819 819
	    break;
820 820
	  default:
821
	    goto error;
821
	    goto invalid_format;
822 822
	}
823
	if (!RB_TYPE_P(key, T_STRING)) goto error;
823
	if (!RB_TYPE_P(key, T_STRING)) goto invalid_format;
824 824
	if (st_lookup(tbl, (st_data_t)RSTRING_PTR(key), 0)) goto error;
825 825
	st_insert(tbl, (st_data_t)RSTRING_PTR(key), (st_data_t)ary);
826 826
    }
827
  invalid_format:
827 828
    st_free_table(tbl);
828 829
    return ary;
829 830

  
830
-