]> xenbits.xensource.com Git - libvirt.git/commitdiff
Avoid some potential FILE * leaks
authorDaniel Veillard <veillard@redhat.com>
Mon, 16 Mar 2009 10:41:37 +0000 (10:41 +0000)
committerDaniel Veillard <veillard@redhat.com>
Mon, 16 Mar 2009 10:41:37 +0000 (10:41 +0000)
* qemud/qemud.c src/cgroup.c src/uml_driver.c src/util.c: close
  some potential FILE * leaks
Daniel

ChangeLog
qemud/qemud.c
src/cgroup.c
src/uml_driver.c
src/util.c

index 921ca8fe889b9557056bcd615015c2b003a06051..19ba4fbcd86310431c6f59dfc3a721763310eae5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Mar 16 11:40:00 CET 2009 Daniel Veillard <veillard@redhat.com>
+
+       * qemud/qemud.c src/cgroup.c src/uml_driver.c src/util.c: close
+         some potential FILE * leaks
+
 Mon Mar 16 10:35:00 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
 
        * qemud/event.c: Fix dispatch of FD events when one or more
index fd315fc20d30b219dc788b2a62281fef95f87a70..4f0435500ce200347f5061adb169c5bb62f73469 100644 (file)
@@ -488,7 +488,7 @@ static int qemudWritePidFile(const char *pidFile) {
     if (fprintf(fh, "%lu\n", (unsigned long)getpid()) < 0) {
         VIR_ERROR(_("Failed to write to pid file '%s' : %s"),
                   pidFile, virStrerror(errno, ebuf, sizeof ebuf));
-        close(fd);
+        fclose(fh);
         return -1;
     }
 
index 5af44bd93ee73602302473d999b3990a11fc0fca..d1d44a2e4575a432479347f4d04a358a0bc4fe59 100644 (file)
@@ -57,7 +57,7 @@ void virCgroupFree(virCgroupPtr *group)
 
 static virCgroupPtr virCgroupGetMount(const char *controller)
 {
-    FILE *mounts;
+    FILE *mounts = NULL;
     struct mntent entry;
     char buf[CGROUP_MAX_VAL];
     virCgroupPtr root = NULL;
@@ -90,6 +90,8 @@ static virCgroupPtr virCgroupGetMount(const char *controller)
 
     return root;
 err:
+    if (mounts != NULL)
+        fclose(mounts);
     virCgroupFree(&root);
 
     return NULL;
index 1dc7ccdfea08b737f357b83741e49a9d7eac0d5d..f7400f958b6a53d9e65b11e619492a7e4ef081c8 100644 (file)
@@ -547,6 +547,7 @@ reopen:
 
     if (fscanf(file, "%d", &vm->pid) != 1) {
         errno = EINVAL;
+        fclose(file);
         goto cleanup;
     }
 
@@ -1040,6 +1041,7 @@ static int umlGetProcessInfo(unsigned long long *cpuTime, int pid) {
 
     if (fscanf(pidinfo, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %llu %llu", &usertime, &systime) != 2) {
         umlDebug("not enough arg");
+        fclose(pidinfo);
         return -1;
     }
 
index 9b74757a4fe13cd5764c67424093867baa4cace5..66ad9a4a3769942e98ff43b0218e10eeeed837b5 100644 (file)
@@ -1058,6 +1058,7 @@ int virFileReadPid(const char *dir,
 
     if (fscanf(file, "%d", pid) != 1) {
         rc = EINVAL;
+        fclose(file);
         goto cleanup;
     }