]> granicus.if.org Git - onig/commitdiff
divide utf16-be/le from encodings
authorK.Kosako <kosako@sofnec.co.jp>
Tue, 23 Jul 2019 06:03:23 +0000 (15:03 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Tue, 23 Jul 2019 06:03:23 +0000 (15:03 +0900)
harnesses/encode-harness.c

index 8c103ba64b47f70b2110b8e817da83bd0063a669..05559fab5763aacd68b2a90cd99219a3240d6f2e 100644 (file)
@@ -126,12 +126,22 @@ int LLVMFuzzerTestOneInput(const uint8_t * Data, size_t Size)
          ONIG_ENCODING_CP1251,
          ONIG_ENCODING_ISO_8859_1,
          ONIG_ENCODING_UTF8,
-          ONIG_ENCODING_UTF16_BE,
-          ONIG_ENCODING_KOI8_R,
-          ONIG_ENCODING_BIG5
+    ONIG_ENCODING_KOI8_R,
+    ONIG_ENCODING_BIG5
   };
+
+  OnigEncodingType *enc;
+
+#ifdef UTF16_BE
+  enc = ONIG_ENCODING_UTF16_BE;
+#else
+#ifdef UTF16_LE
+  enc = ONIG_ENCODING_UTF16_LE;
+#else
   int num_encodings = sizeof(encodings)/sizeof(encodings[0]);
-  OnigEncodingType *enc = encodings[encoding_choice % num_encodings];
+  enc = encodings[encoding_choice % num_encodings];
+#endif
+#endif
 
   r = exec(enc, ONIG_OPTION_NONE, (char *)pattern, (char *)pattern_end,
            (char *)str, (char *)str_null_end);