summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido Cella <guido@guidocella.xyz>2021-06-20 17:10:39 +0200
committerDudemanguy <random342@airmail.cc>2021-06-21 15:36:30 +0000
commitf70995cc9b435f0d26ee3e6a54e4875f6fde8e20 (patch)
treec4dbf3db987d552b61f3d996bb4633767294560b
parent48f3a267460f8ca2355a8168e0694e7251b2f5d3 (diff)
downloadmpv-f70995cc9b435f0d26ee3e6a54e4875f6fde8e20.tar.bz2
mpv-f70995cc9b435f0d26ee3e6a54e4875f6fde8e20.tar.xz
player: fix segfault
Commit 029ff10 added a goto statement which skipped initializing the `lang' variable. This could crash depending on compiler optimizations and other factors: if the lang bstr pointer happened to end up NULL (which is apparently the case with most compilers) then it's validly empty, but if it pointed to a random and incorrect memory address then it crashed. The crash was observed when mpv was compiled using gcc 10.2 with optimizations enabled, and affected some third party Windows builds. This commit ensures the goto doesn't skip the initialization. Thanks to votemp for figuring this out. Fixes #8922.
-rw-r--r--player/external_files.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/player/external_files.c b/player/external_files.c
index 449e62d623..0e3fad73f7 100644
--- a/player/external_files.c
+++ b/player/external_files.c
@@ -224,10 +224,9 @@ static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts,
(type != STREAM_VIDEO || (fuzz != 1 && bstrcmp(dename, f_fname) != 0)))
prio |= 32; // exact movie name match
+ bstr lang = {0};
if (type == STREAM_VIDEO)
goto cover_art;
-
- bstr lang = {0};
if (bstr_startswith(tmp_fname_trim, f_fname_trim)) {
int start = 0;
lang = guess_lang_from_filename(tmp_fname_trim, &start);