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`
Unified · Split
| @@ -255,9 +255,10 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, · 254 unmodified lines | |||
| 255 | if (*opt == '/') { | 255 | if (*opt == '/') { |
| 256 | opt++; | 256 | opt++; |
| 257 | 257 | ||
| 258 | if (po->type == OPT_TYPE_BOOL) { | 258 | if (!opt_has_arg(po)) { |
| 259 | av_log(NULL, AV_LOG_FATAL, | 259 | av_log(NULL, AV_LOG_FATAL, |
| 260 | "Requested to load an argument from file for a bool option '%s'\n", | 260 | "Requested to load an argument from file for an option '%s'" |
| 261 | " which does not take an argument\n", | ||
| 261 | po->name); | 262 | po->name); |
| 262 | return AVERROR(EINVAL); | 263 | return AVERROR(EINVAL); |
| 263 | } | 264 | } |