]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/fuzzer/uloc_open_keywords_fuzzer.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / test / fuzzer / uloc_open_keywords_fuzzer.cpp
diff --git a/icuSources/test/fuzzer/uloc_open_keywords_fuzzer.cpp b/icuSources/test/fuzzer/uloc_open_keywords_fuzzer.cpp
new file mode 100644 (file)
index 0000000..db9d967
--- /dev/null
@@ -0,0 +1,20 @@
+// © 2019 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include <string>
+
+#include "locale_util.h"
+#include "unicode/uenum.h"
+#include "unicode/uloc.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+  const std::string input = MakeZeroTerminatedInput(data, size);
+
+  UErrorCode status = U_ZERO_ERROR;
+  UEnumeration* enumeration = uloc_openKeywords(input.c_str(), &status);
+
+  // Have to clean up. Call works even for nullptr enumeration.
+  uenum_close(enumeration);
+
+  return 0;
+}