[systemd-devel] [PATCH] sysv-generator: do not dereference uninitilized data or NULL pointer

Shawn Landden shawn at churchofgit.com
Sun Apr 26 11:19:57 PDT 2015


(coverity)

v2
---
 src/sysv-generator/sysv-generator.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 5ecd750..f56d727 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -99,6 +99,9 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(SysvStub*, free_sysvstub);
 static void free_sysvstub_hashmapp(Hashmap **h) {
         SysvStub *stub;
 
+        if (h == NULL)
+                return;
+
         while ((stub = hashmap_steal_first(*h)))
                 free_sysvstub(stub);
 
@@ -922,7 +925,7 @@ finish:
 int main(int argc, char *argv[]) {
         int r, q;
         _cleanup_lookup_paths_free_ LookupPaths lp = {};
-        _cleanup_(free_sysvstub_hashmapp) Hashmap *all_services;
+        _cleanup_(free_sysvstub_hashmapp) Hashmap *all_services = NULL;
         SysvStub *service;
         Iterator j;
 
-- 
2.2.1.209.g41e5f3a



More information about the systemd-devel mailing list