Skip to content

Commit 38100f8

Browse files
committed
Fix crash in jsonexpr command line tool when no argument provided
1 parent 67650c8 commit 38100f8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

jsonexpr/src/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ int main(int argc, const char* argv[]) {
3434
for (const auto& [key, value] : data.items()) {
3535
vars[key] = value;
3636
}
37-
} else {
37+
} else if (argc == 2) {
3838
expression = argv[1];
39+
} else {
40+
std::cerr << "error: no expression provided" << std::endl;
41+
return 1;
3942
}
4043

4144
const auto result = jsonexpr::evaluate(expression, vars, funcs);

0 commit comments

Comments
 (0)