@@ -1092,3 +1092,40 @@ func TestEmptyCaptureLargeRepeat(t *testing.T) {
10921092 t .Fatal ("Expected 2 matches, got more" )
10931093 }
10941094}
1095+
1096+ func TestFuzzBytes (t * testing.T ) {
1097+ //some crash cases found from fuzzing
1098+
1099+ var testCases = []struct {
1100+ r , s []byte
1101+ }{
1102+ {
1103+ r : []byte {0x28 , 0x28 , 0x29 , 0x5c , 0x37 , 0x28 , 0x3f , 0x28 , 0x29 , 0x29 },
1104+ s : []byte {0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 },
1105+ },
1106+ {
1107+ r : []byte {0x28 , 0x5c , 0x32 , 0x28 , 0x3f , 0x28 , 0x30 , 0x29 , 0x29 },
1108+ s : []byte {0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 },
1109+ },
1110+ {
1111+ r : []byte {0x28 , 0x3f , 0x28 , 0x29 , 0x29 , 0x5c , 0x31 , 0x30 , 0x28 , 0x3f , 0x28 , 0x30 , 0x29 },
1112+ s : []byte {0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 },
1113+ },
1114+ {
1115+ r : []byte {0x28 , 0x29 , 0x28 , 0x28 , 0x29 , 0x5c , 0x37 , 0x28 , 0x3f , 0x28 , 0x29 , 0x29 },
1116+ s : []byte {0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 , 0x30 },
1117+ },
1118+ }
1119+
1120+ for _ , c := range testCases {
1121+ r := string (c .r )
1122+ t .Run (r , func (t * testing.T ) {
1123+ _ , err := Compile (r , Multiline | ECMAScript | Debug )
1124+ // should fail compiling
1125+ if err == nil {
1126+ t .Fatal ("should fail compile, but didn't" )
1127+ }
1128+ })
1129+ }
1130+
1131+ }
0 commit comments