Print this page
2831 svc.startd and svc.configd waste memory.

@@ -19,10 +19,11 @@
  * CDDL HEADER END
  */
 
 /*
  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  */
 
 #include <libintl.h>
 #include <librestart.h>
 #include <librestart_priv.h>

@@ -3331,10 +3332,14 @@
          * A method_context was not used for any configurable
          * elements or attributes, so reset and use the simple
          * defaults that provide historic init behavior.
          */
         if (mc_used == 0) {
+                free(cip->pwbuf);
+                free(cip->vbuf);
+                free(cip->working_dir);
+
                 (void) memset(cip, 0, sizeof (*cip));
                 cip->uid = 0;
                 cip->gid = 0;
                 cip->euid = (uid_t)-1;
                 cip->egid = (gid_t)-1;

@@ -3346,12 +3351,15 @@
         (void) scf_value_destroy(val);
         scf_property_destroy(prop);
         scf_pg_destroy(instpg);
         scf_pg_destroy(methpg);
 
-        if (cip->pwbuf != NULL)
+        if (cip->pwbuf != NULL) {
                 free(cip->pwbuf);
+                cip->pwbuf = NULL;
+        }
+
         free(cip->vbuf);
 
         if (err->type != 0) {
                 restarter_free_method_context(cip);
         } else {