Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Unified Diff: test/fuzzer/regexp.cc

Issue 2511373002: [regexp fuzzer] Let the fuzzer input select the regexp flag. (Closed)
Patch Set: Reintroduce the GC call. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/fuzzer/regexp.cc
diff --git a/test/fuzzer/regexp.cc b/test/fuzzer/regexp.cc
index 4b053d4eb915e7926ef1d70962ea1a9fbf0f447a..551abcb1bd3f0fb6448b7f2f6e6b0f2a834914fe 100644
--- a/test/fuzzer/regexp.cc
+++ b/test/fuzzer/regexp.cc
@@ -57,23 +57,23 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
factory->NewStringFromTwoByte(i::Vector<const i::uc16>(two_byte_array, 6))
.ToHandleChecked();
- for (int flags = 0; flags <= kAllFlags; flags++) {
- i::Handle<i::JSRegExp> regexp;
- {
- v8::TryCatch try_catch(isolate);
- i::MaybeHandle<i::JSRegExp> maybe_regexp =
- i::JSRegExp::New(source, static_cast<i::JSRegExp::Flags>(flags));
- if (!maybe_regexp.ToHandle(&regexp)) {
- i_isolate->clear_pending_exception();
- continue;
- }
+ i::Handle<i::JSRegExp> regexp;
+ {
+ v8::TryCatch try_catch(isolate);
+ // Create a string so that we can calculate a hash from the input data.
+ std::string str = std::string(reinterpret_cast<const char*>(data), size);
+ i::JSRegExp::Flags flag = static_cast<i::JSRegExp::Flags>(
+ std::hash<std::string>()(str) % (kAllFlags + 1));
+ i::MaybeHandle<i::JSRegExp> maybe_regexp = i::JSRegExp::New(source, flag);
+ if (!maybe_regexp.ToHandle(&regexp)) {
+ i_isolate->clear_pending_exception();
+ return 0;
}
- Test(isolate, regexp, one_byte, results_array);
- Test(isolate, regexp, two_byte, results_array);
- Test(isolate, regexp, factory->empty_string(), results_array);
- Test(isolate, regexp, source, results_array);
}
-
+ Test(isolate, regexp, one_byte, results_array);
+ Test(isolate, regexp, two_byte, results_array);
+ Test(isolate, regexp, factory->empty_string(), results_array);
+ Test(isolate, regexp, source, results_array);
isolate->RequestGarbageCollectionForTesting(
v8::Isolate::kFullGarbageCollection);
return 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698