From 3ade6dacfc44673aff812ecafc0830ae42334840 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 27 Nov 2019 10:27:00 +0100 Subject: [PATCH] dispatcher: use free() to free memory allocated with malloc() In practice, nowadays g_free() is the same as free(), so there is no difference. However, we still should not mix the two and use free() for data that was allocated with malloc() -- in this case, the memory was allocated by libc's realpath(). --- dispatcher/nm-dispatcher.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dispatcher/nm-dispatcher.c b/dispatcher/nm-dispatcher.c index a2d8cf898a..0bc2e9fb3e 100644 --- a/dispatcher/nm-dispatcher.c +++ b/dispatcher/nm-dispatcher.c @@ -638,14 +638,15 @@ static gboolean script_must_wait (const char *path) { gs_free char *link = NULL; - gs_free char *dir = NULL; - gs_free char *real = NULL; - char *tmp; - link = g_file_read_link (path, NULL); if (link) { + gs_free char *dir = NULL; + nm_auto_free char *real = NULL; + if (!g_path_is_absolute (link)) { + char *tmp; + dir = g_path_get_dirname (path); tmp = g_build_path ("/", dir, link, NULL); g_free (link);