1b5975d6bSopenharmony_ciFrom f95ca6cb713383548f16f9a8ba2f6c51a4d25e25 Mon Sep 17 00:00:00 2001 2b5975d6bSopenharmony_ciFrom: Michael Catanzaro <mcatanzaro@redhat.com> 3b5975d6bSopenharmony_ciDate: Fri, 17 Jun 2022 08:48:10 -0500 4b5975d6bSopenharmony_ciSubject: [PATCH] xdgmime: fix double free 5b5975d6bSopenharmony_ci 6b5975d6bSopenharmony_ciWe free xdg_dirs[i] twice, but fail to free xdg_dirs itself. 7b5975d6bSopenharmony_ci 8b5975d6bSopenharmony_ciAlso, since free() is NULL-safe, there is no need for the second check 9b5975d6bSopenharmony_cihere. 10b5975d6bSopenharmony_ci 11b5975d6bSopenharmony_ciDiscovered in: https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/16#note_1432025 12b5975d6bSopenharmony_ci 13b5975d6bSopenharmony_ciConflict:NA 14b5975d6bSopenharmony_ciReference:https://gitlab.gnome.org/GNOME/glib/-/commit/f95ca6cb713383548f16f9a8ba2f6c51a4d25e25 15b5975d6bSopenharmony_ci 16b5975d6bSopenharmony_ci--- 17b5975d6bSopenharmony_ci gio/xdgmime/xdgmime.c | 3 +-- 18b5975d6bSopenharmony_ci 1 file changed, 1 insertion(+), 2 deletions(-) 19b5975d6bSopenharmony_ci 20b5975d6bSopenharmony_cidiff --git a/gio/xdgmime/xdgmime.c b/gio/xdgmime/xdgmime.c 21b5975d6bSopenharmony_ciindex 9ab6760486..c3c11625e8 100644 22b5975d6bSopenharmony_ci--- a/gio/xdgmime/xdgmime.c 23b5975d6bSopenharmony_ci+++ b/gio/xdgmime/xdgmime.c 24b5975d6bSopenharmony_ci@@ -350,8 +350,7 @@ xdg_mime_set_dirs (const char * const *dirs) 25b5975d6bSopenharmony_ci 26b5975d6bSopenharmony_ci for (i = 0; xdg_dirs != NULL && xdg_dirs[i] != NULL; i++) 27b5975d6bSopenharmony_ci free (xdg_dirs[i]); 28b5975d6bSopenharmony_ci- if (xdg_dirs != NULL) 29b5975d6bSopenharmony_ci- free (xdg_dirs[i]); 30b5975d6bSopenharmony_ci+ free (xdg_dirs); 31b5975d6bSopenharmony_ci xdg_dirs = NULL; 32b5975d6bSopenharmony_ci 33b5975d6bSopenharmony_ci if (dirs != NULL) 34b5975d6bSopenharmony_ci-- 35b5975d6bSopenharmony_ciGitLab 36b5975d6bSopenharmony_ci 37