Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
If callbacks were NULL then ca_parse would crash instead of not calling them
  • Loading branch information
ethanuppal committed Mar 7, 2024
1 parent cb3bf9a commit 3d494bf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/cmdapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,11 +742,15 @@ int ca_parse(void* user_data) {
&& strcmp(result.opt->long_opt, "version") == 0) {
ca_print_version();
} else {
app.opt_callback(result.opt->short_opt, result.opt->long_opt,
result.arg, user_data);
if (app.opt_callback) {
app.opt_callback(result.opt->short_opt,
result.opt->long_opt, result.arg, user_data);
}
}
} else {
app.arg_callback(result.arg, user_data);
if (app.arg_callback) {
app.arg_callback(result.arg, user_data);
}
}
}

Expand Down

0 comments on commit 3d494bf

Please sign in to comment.