[systemd-devel] [PATCH 1/4] install: fix invalid free() in unit_file_mask()

Andreas Henriksson andreas at fatal.se
Fri Jun 13 09:48:18 PDT 2014


int unit_file_mask(...) in ./src/shared/install.c calls
get_config_path(...) which can in 4 error cases return without setting
"ret", and thus "prefix" can be uninitialized when unit_file_mask(...)
finishes (which it does directly after the error is returned from
get_config_path(...)).

Signed-off-by: Andreas Henriksson <andreas at fatal.se>
---
 src/shared/install.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/install.c b/src/shared/install.c
index 487d0f6..f562063 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -563,7 +563,7 @@ int unit_file_mask(
                 unsigned *n_changes) {
 
         char **i;
-        _cleanup_free_ char *prefix;
+        _cleanup_free_ char *prefix = NULL;
         int r;
 
         assert(scope >= 0);
-- 
2.0.0



More information about the systemd-devel mailing list