summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2023-06-28 04:16:48 +0600
committerrcombs <rcombs@rcombs.me>2023-06-28 14:45:13 -0500
commit2f220c6286cdf63988aea05811db3f315abe16ea (patch)
tree57b8a71a0e4fa90505ef13fe2768dbb406874583 /player/loadfile.c
parentf8cb539e6ffce52b370964bd45efe1424aacac53 (diff)
downloadmpv-2f220c6286cdf63988aea05811db3f315abe16ea.tar.bz2
mpv-2f220c6286cdf63988aea05811db3f315abe16ea.tar.xz
loadfile: fix leak due to setting NULL parent
in the first iteration, *out will be null and thus the steal and the strdup both sets the parent to NULL - leaking the allocation later on (caught via LeakSanitizer). let append_lang() take care of setting the parent instead.
Diffstat (limited to 'player/loadfile.c')
-rw-r--r--player/loadfile.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index aeca0d42a1..f11bb5bad1 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -544,6 +544,7 @@ static bool append_lang(size_t *nb, char ***out, char *in)
MP_TARRAY_GROW(NULL, *out, *nb + 1);
(*out)[(*nb)++] = in;
(*out)[*nb] = NULL;
+ ta_set_parent(in, *out);
return true;
}
@@ -552,7 +553,7 @@ static bool add_auto_langs(size_t *nb, char ***out)
bool ret = false;
char **autos = mp_get_user_langs();
for (int i = 0; autos && autos[i]; i++) {
- if (!append_lang(nb, out, talloc_steal(*out, autos[i])))
+ if (!append_lang(nb, out, autos[i]))
goto cleanup;
}
ret = true;
@@ -571,7 +572,7 @@ static char **process_langs(char **in)
if (!add_auto_langs(&nb, &out))
break;
} else {
- if (!append_lang(&nb, &out, talloc_strdup(out, in[i])))
+ if (!append_lang(&nb, &out, talloc_strdup(NULL, in[i])))
break;
}
}