Check precondition before calling set_execution_mode

set_execution_mode has an assertion that amounts to a precondition requiring that its input parameters have been validated. This causes hhvm to assert and crash if the user specifies an invalid mode on the command line.
Esse commit está contido em:
Herman Venter
2013-06-12 15:32:08 -07:00
commit de sgolemon
commit 1cd7eb316e
+10 -3
Ver Arquivo
@@ -864,13 +864,20 @@ static int execute_program_impl(int argc, char **argv) {
if (po.mode == "s") po.mode = "server";
if (po.mode == "t") po.mode = "translate";
if (po.mode == "") po.mode = "run";
set_execution_mode(po.mode);
if (po.mode == "daemon" || po.mode == "server" || po.mode == "replay" ||
po.mode == "run" || po.mode == "debug"|| po.mode == "translate") {
set_execution_mode(po.mode);
} else {
Logger::Error("Error in command line: invalid mode: %s", po.mode.c_str());
cout << desc << "\n";
return -1;
}
} catch (error &e) {
Logger::Error("Error in command line: %s\n\n", e.what());
Logger::Error("Error in command line: %s", e.what());
cout << desc << "\n";
return -1;
} catch (...) {
Logger::Error("Error in command line:\n\n");
Logger::Error("Error in command line.");
cout << desc << "\n";
return -1;
}