aidl: Options - avoid calling exit(3)
The fuzzer considers this a fatal error.
Bug: 195473218
Test: aidl_unittests + the following commands:
# in a directory without a file named
# 'alskdjflsakdjflkasjdflkajdslfkajsdf', this command fails:
aidl alskdjflsakdjflkasjdflkajdslfkajsdf
# this command returns a successful result, and nothing else is done
aidl --help
Change-Id: I9c0509dae8c4516d8ca57b7a203b51acb5848725
diff --git a/options.cpp b/options.cpp
index a4dafba..b79c4f1 100644
--- a/options.cpp
+++ b/options.cpp
@@ -26,6 +26,7 @@
#include <sstream>
#include <string>
+#include <android-base/logging.h>
#include <android-base/strings.h>
#include "aidl_language.h"
@@ -368,14 +369,17 @@
break;
case 'e':
std::cerr << GetUsage();
- exit(0);
+ task_ = Task::HELP;
+ CHECK(Ok());
+ return;
case 'i':
output_file_ = Trim(optarg);
task_ = Task::DUMP_MAPPINGS;
break;
default:
- std::cerr << GetUsage();
- exit(1);
+ error_message_ << GetUsage();
+ CHECK(!Ok());
+ return;
}
} // while