Fixes for several memory leaks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Index: libvirt/src/conf/secret_conf.c

===================================================================

***************

*** 154,160 ****

                                   _("invalid value of 'private'"));

              goto cleanup;

          }

-         VIR_FREE(prop);

      }

 

      uuidstr = virXPathString("string(./uuid)", ctxt);

--- 154,159 ----

***************

*** 170,176 ****

                                   "%s", _("malformed uuid element"));

              goto cleanup;

          }

-         VIR_FREE(uuidstr);

      }

 

      def->description = virXPathString("string(./description)", ctxt);

--- 169,174 ----

***************

*** 181,187 ****

      def = NULL;

 

   cleanup:

!     VIR_FREE(prop);

      virSecretDefFree(def);

      xmlXPathFreeContext(ctxt);

      return ret;

--- 179,190 ----

      def = NULL;

 

   cleanup:

!     if (prop) {

!         VIR_FREE(prop);

!     }

!     if (uuidstr) {

!         VIR_FREE(uuidstr);

!     }

      virSecretDefFree(def);

      xmlXPathFreeContext(ctxt);

      return ret;

 

Index: libvirt/src/nwfilter/nwfilter_gentech_driver.c

===================================================================

***************

*** 662,673 ****

          }

 

          virNWFilterUnlockIface(ifname);

-

-         VIR_FREE(ptrs);

      }

 

  err_exit:

 

      virNWFilterUnlockFilterUpdates();

 

      for (j = 0; j < nEntries; j++)

--- 662,675 ----

          }

 

          virNWFilterUnlockIface(ifname);

      }

 

  err_exit:

 

+     if (ptrs) {

+         VIR_FREE(ptrs);

+     }

+

      virNWFilterUnlockFilterUpdates();

 

      for (j = 0; j < nEntries; j++)

 

Index: libvirt/src/remote/remote_driver.c

===================================================================

***************

*** 474,495 ****

--- 474,510 ----

          for (i = 0; i < vars->n; i++) {

              var = &vars->p[i];

              if (STRCASEEQ (var->name, "name")) {

+                 if (name) {

+                     VIR_FREE(name);

+                 }

                  name = strdup (var->value);

                  if (!name) goto out_of_memory;

                  var->ignore = 1;

              } else if (STRCASEEQ (var->name, "command")) {

+                 if (command) {

+                     VIR_FREE(command);

+                 }

                  command = strdup (var->value);

                  if (!command) goto out_of_memory;

                  var->ignore = 1;

              } else if (STRCASEEQ (var->name, "socket")) {

+                 if (sockname) {

+                     VIR_FREE(sockname);

+                 }

                  sockname = strdup (var->value);

                  if (!sockname) goto out_of_memory;

                  var->ignore = 1;

              } else if (STRCASEEQ (var->name, "auth")) {

+                 if (authtype) {

+                     VIR_FREE(authtype);

+                 }

                  authtype = strdup (var->value);

                  if (!authtype) goto out_of_memory;

                  var->ignore = 1;

              } else if (STRCASEEQ (var->name, "netcat")) {

+                 if (netcat) {

+                     VIR_FREE(netcat);

+                 }

                  netcat = strdup (var->value);

                  if (!netcat) goto out_of_memory;

                  var->ignore = 1;

 

Index: libvirt/src/util/conf.c

===================================================================

***************

*** 651,656 ****

--- 651,657 ----

      SKIP_BLANKS;

      if (CUR != '=') {

          virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("expecting an assignment"));

+         VIR_FREE(name);

          return(-1);

      }

      NEXT;

 

Index: libvirt/src/util/storage_file.c

===================================================================

***************

*** 742,747 ****

--- 742,748 ----

      if (format < 0 ||

          format >= VIR_STORAGE_FILE_LAST) {

          virReportSystemError(EINVAL, _("unknown storage file format %d"), format);

+         VIR_FREE(head);

          return -1;

      }

 

 

Index: libvirt/src/util/xml.c

===================================================================

***************

*** 107,113 ****

          virXMLError(VIR_ERR_INTERNAL_ERROR,

                      _("\'%s\' value longer than %Zd bytes in virXPathStringLimit()"),

                      xpath, maxlen);

!             return NULL;

      }

 

      return tmp;

--- 107,114 ----

          virXMLError(VIR_ERR_INTERNAL_ERROR,

                      _("\'%s\' value longer than %Zd bytes in virXPathStringLimit()"),

                      xpath, maxlen);

!         VIR_FREE(tmp);

!         return NULL;

      }

 

      return tmp;

 

Index: libvirt/tools/virsh.c

===================================================================

***************

*** 8697,8702 ****

--- 8697,8703 ----

  {

      const char *dir;

      int found;

+     int dir_root = FALSE;

 

      if (!ctl->imode) {

          vshError(ctl, "%s", _("cd: command valid only in interactive mode"));

***************

*** 8708,8721 ****

          uid_t uid = geteuid();

          dir = virGetUserDirectory(uid);

      }

!     if (!dir)

          dir = "/";

 

      if (chdir (dir) == -1) {

          vshError(ctl, _("cd: %s: %s"), strerror(errno), dir);

          return FALSE;

      }

 

      return TRUE;

  }

 

--- 8709,8730 ----

          uid_t uid = geteuid();

          dir = virGetUserDirectory(uid);

      }

!     if (!dir) {

          dir = "/";

+         dir_root = TRUE;

+     }

 

      if (chdir (dir) == -1) {

          vshError(ctl, _("cd: %s: %s"), strerror(errno), dir);

+         if (!dir_root) {

+             VIR_FREE(dir);

+         }

          return FALSE;

      }

 

+     if (!dir_root) {

+         VIR_FREE(dir);

+     }

      return TRUE;

  }

 

Kind regards,

Phil Petty

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]