[systemd-devel] [PATCH 1/2] path-util: set pointer to null after calling free()

Michal Sekletar msekleta at redhat.com
Thu Dec 13 05:59:39 PST 2012


In cases where path_strv_canonicalize() returns NULL, strv_free() is
called afterwards and it will call free() on pointers which were freed
already in path_strv_canonicalize()
---
 src/shared/path-util.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index 70c8a8a..dd12d3d 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -181,6 +181,7 @@ char **path_strv_canonicalize(char **l) {
 
                 t = path_make_absolute_cwd(*s);
                 free(*s);
+                *s = NULL;
 
                 if (!t) {
                         enomem = true;
-- 
1.7.11.7



More information about the systemd-devel mailing list