xdgmime: fix double free

We free xdg_dirs[i] twice, but fail to free xdg_dirs itself.

Also, since free() is NULL-safe, there is no need for the second check
here.

Discovered in: https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/16#note_1432025

(cherry-picked from commit f95ca6cb71)
This commit is contained in:
Michael Catanzaro
2022-06-17 08:48:10 -05:00
committed by Marco Trevisan (Treviño)
parent 38d727524a
commit 3f10df2d7b

View File

@@ -350,8 +350,7 @@ xdg_mime_set_dirs (const char * const *dirs)
for (i = 0; xdg_dirs != NULL && xdg_dirs[i] != NULL; i++)
free (xdg_dirs[i]);
if (xdg_dirs != NULL)
free (xdg_dirs[i]);
free (xdg_dirs);
xdg_dirs = NULL;
if (dirs != NULL)