chiark / gitweb /
path-util: set pointer to null after calling free()
authorMichal Sekletar <msekleta@redhat.com>
Thu, 13 Dec 2012 13:59:39 +0000 (14:59 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 17 Dec 2012 10:41:31 +0000 (11:41 +0100)
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

index 70c8a8af06f9b2ea9db57784db96a405dc272e88..dd12d3d63409654fb446028ba92a0860bc83e4c1 100644 (file)
@@ -181,6 +181,7 @@ char **path_strv_canonicalize(char **l) {
 
                 t = path_make_absolute_cwd(*s);
                 free(*s);
+                *s = NULL;
 
                 if (!t) {
                         enomem = true;