Skip to content

Commit

Permalink
demux_lavf: fix demuxer-lavf-format usage
Browse files Browse the repository at this point in the history
mpv internally treats all string options/properties with NULL or an empty string the same way. client.h explicitly forbids MPV_FORMAT_STRING from being NULL, but in the C API, it has been working accidentally due to how strings are copied. Nevertheless, none of the APIs allow this; JavaScript, Lua, IPC, and CLI all require strings to be at least empty. We cannot pass NULL.

Furthermore, currently passing NULL causes an assertion failure in the JSON formatter, so it is clearly not intended to be used that way.

Internally, all string options default to NULL, but in this case, they should behave exactly the same as an empty string. Hence, this change is applied to the `demuxer-lavf-format` option.

Note that get_property will never return a NULL value, regardless of the internal value.

Fixes: #15840
  • Loading branch information
kasper93 committed Feb 10, 2025
1 parent 73b8459 commit f385a6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion demux/demux_lavf.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)

const AVInputFormat *forced_format = NULL;
const char *format = lavfdopts->format;
if (!format)
if (!format || !format[0])
format = s->lavf_type;
if (!format)
format = avdevice_format;
Expand Down

0 comments on commit f385a6b

Please sign in to comment.