fftools/cmdutils: don't try to load arguments from file if not needed

CLI option parser checks if argument exists when needed, but in this
case only OPT_TYPE_BOOL where checked, so OPT_TYPE_FUNC without argument
where trying to load a file from `arg` which is NULL in this case.

Fixes crash on `ffmpeg -/version`

Fixes: 6d17991b7e
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5f62e2de98)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Kacper Michajłow 2025-06-30 20:36:09 +02:00 committed by Michael Niedermayer
parent 541b670e29
commit 50538d59b1
No known key found for this signature in database
GPG key ID: B18E8928B3948D64

View file

@ -256,9 +256,10 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
if (*opt == '/') { if (*opt == '/') {
opt++; opt++;
if (po->type == OPT_TYPE_BOOL) { if (!opt_has_arg(po)) {
av_log(NULL, AV_LOG_FATAL, av_log(NULL, AV_LOG_FATAL,
"Requested to load an argument from file for a bool option '%s'\n", "Requested to load an argument from file for an option '%s'"
" which does not take an argument\n",
po->name); po->name);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }