Clear 'sHadError' in entry point.
The fuzzer invokes aidl_entry multiple times in a single run, and if one
of these runs through an error and one succeeds, we are unnecessarily
hitting this check.
We could make this problem go away by passing around a 'context' object
instead. This is something to consider if we run into this type of thing
again.
Fixes: 153709262
Test: fuzzer, see added corpus entry
Change-Id: I4eb96456e1e24790cc667b8e414c6c34e8814d87
diff --git a/aidl.cpp b/aidl.cpp
index 5495410..64d28eb 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -861,6 +861,8 @@
}
int aidl_entry(const Options& options, const IoDelegate& io_delegate) {
+ AidlErrorLog::clearError();
+
int ret = 1;
switch (options.GetTask()) {
case Options::Task::COMPILE:
diff --git a/aidl_language.h b/aidl_language.h
index 5f08504..16822b0 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -152,6 +152,7 @@
std::ostream& os_;
+ static void clearError() { sHadError = false; }
static bool hadError() { return sHadError; }
private:
diff --git a/tests/corpus/fails_only_in_java b/tests/corpus/fails_only_in_java
new file mode 100644
index 0000000..640a650
--- /dev/null
+++ b/tests/corpus/fails_only_in_java
@@ -0,0 +1 @@
+&enum l{p}parcelable e{Map y0;}
\ No newline at end of file