diff --git a/hphp/runtime/base/builtin_functions.cpp b/hphp/runtime/base/builtin_functions.cpp index 0eb8e40bc..1131f8882 100644 --- a/hphp/runtime/base/builtin_functions.cpp +++ b/hphp/runtime/base/builtin_functions.cpp @@ -1047,11 +1047,9 @@ Variant invoke_file(CStrRef s, bool once, const char *currentDir) { SystemGlobals* g = (SystemGlobals*)get_global_variables(); Variant& v_argc = g->GV(argc); Variant& v_argv = g->GV(argv); - if (!more(v_argc, int64_t(1))) { + if (!more(v_argc, int64_t(0))) { return true; } - v_argc--; - v_argv.dequeue(); String s2 = toString(v_argv.rvalAt(int64_t(0), AccessFlags::Error)); if (invoke_file_impl(r, s2, once, "")) { return r; diff --git a/hphp/runtime/base/program_functions.cpp b/hphp/runtime/base/program_functions.cpp index c4e8512da..daac9395d 100644 --- a/hphp/runtime/base/program_functions.cpp +++ b/hphp/runtime/base/program_functions.cpp @@ -683,7 +683,7 @@ static void prepare_args(int &argc, char **&argv, const StringVec &args, const char *file) { argv = (char **)malloc((args.size() + 2) * sizeof(char*)); argc = 0; - if (file) { + if (*file) { argv[argc++] = (char*)file; } for (int i = 0; i < (int)args.size(); i++) { @@ -1031,8 +1031,8 @@ static int execute_program_impl(int argc, char **argv) { if (!po.file.empty()) { Repo::setCliFile(po.file); - } else if (new_argc >= 2) { - Repo::setCliFile(new_argv[1]); + } else if (new_argc >= 1) { + Repo::setCliFile(new_argv[0]); } int ret = 0; diff --git a/hphp/test/slow/program_functions/1235.php b/hphp/test/slow/program_functions/1235.php index 586d5454a..8a115dffe 100644 --- a/hphp/test/slow/program_functions/1235.php +++ b/hphp/test/slow/program_functions/1235.php @@ -1,3 +1,3 @@