Browse Source

lib: fix memory leak in zprivs_caps_init

Lou Berger 5 years ago
parent
commit
b8cb7c3fd4
1 changed files with 7 additions and 0 deletions
  1. 7 0
      lib/privs.c

+ 7 - 0
lib/privs.c

@@ -307,11 +307,18 @@ zprivs_caps_init (struct zebra_privs_t *zprivs)
 
       current_caps = cap_get_proc();
       if (current_caps)
+        {
           current_caps_text = cap_to_text(current_caps, NULL);
+          cap_free(current_caps);
+        }
 
       wanted_caps_text = cap_to_text(zprivs_state.caps, NULL);
       fprintf(stderr, "Wanted caps: %s\n", wanted_caps_text ? wanted_caps_text : "???");
       fprintf(stderr, "Have   caps: %s\n", current_caps_text ? current_caps_text : "???");
+      if (current_caps_text)
+          cap_free(current_caps_text);
+      if (wanted_caps_text)
+          cap_free(wanted_caps_text);
 
       exit (1);
     }