Skip to content

Commit 93c9c87

Browse files
committed
Check that the arguments vector is not empty
1 parent b497a1c commit 93c9c87

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

python_bindings/src/halide/halide_/PyGenerator.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ void define_generator(py::module &m) {
159159

160160
m.def("_generate_filter_main", //
161161
[](const std::vector<std::string> &arguments) -> void {
162+
if (arguments.empty()) {
163+
throw std::invalid_argument("No arguments provided to _generate_filter_main");
164+
}
165+
162166
// POSIX requires argv to be mutable and null-terminated
163167
std::vector<char *> argv;
164168
argv.reserve(arguments.size() + 1);
@@ -168,7 +172,7 @@ void define_generator(py::module &m) {
168172
argv.push_back(nullptr);
169173

170174
const int result = Halide::Internal::generate_filter_main(
171-
(int)argv.size() - 1, argv.data(), PyGeneratorFactoryProvider());
175+
static_cast<int>(argv.size()) - 1, argv.data(), PyGeneratorFactoryProvider());
172176
if (result != 0) {
173177
// Some paths in generate_filter_main() will fail with user_error
174178
// or similar (which throws an exception due to how libHalide is

0 commit comments

Comments
 (0)