提交 aa08419c 编写于 作者: D Daniel Veillard

Avoid some potential FILE * leaks

* qemud/qemud.c src/cgroup.c src/uml_driver.c src/util.c: close
  some potential FILE * leaks
Daniel
上级 29ed758a
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> 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 * qemud/event.c: Fix dispatch of FD events when one or more
......
...@@ -488,7 +488,7 @@ static int qemudWritePidFile(const char *pidFile) { ...@@ -488,7 +488,7 @@ static int qemudWritePidFile(const char *pidFile) {
if (fprintf(fh, "%lu\n", (unsigned long)getpid()) < 0) { if (fprintf(fh, "%lu\n", (unsigned long)getpid()) < 0) {
VIR_ERROR(_("Failed to write to pid file '%s' : %s"), VIR_ERROR(_("Failed to write to pid file '%s' : %s"),
pidFile, virStrerror(errno, ebuf, sizeof ebuf)); pidFile, virStrerror(errno, ebuf, sizeof ebuf));
close(fd); fclose(fh);
return -1; return -1;
} }
......
...@@ -57,7 +57,7 @@ void virCgroupFree(virCgroupPtr *group) ...@@ -57,7 +57,7 @@ void virCgroupFree(virCgroupPtr *group)
static virCgroupPtr virCgroupGetMount(const char *controller) static virCgroupPtr virCgroupGetMount(const char *controller)
{ {
FILE *mounts; FILE *mounts = NULL;
struct mntent entry; struct mntent entry;
char buf[CGROUP_MAX_VAL]; char buf[CGROUP_MAX_VAL];
virCgroupPtr root = NULL; virCgroupPtr root = NULL;
...@@ -90,6 +90,8 @@ static virCgroupPtr virCgroupGetMount(const char *controller) ...@@ -90,6 +90,8 @@ static virCgroupPtr virCgroupGetMount(const char *controller)
return root; return root;
err: err:
if (mounts != NULL)
fclose(mounts);
virCgroupFree(&root); virCgroupFree(&root);
return NULL; return NULL;
......
...@@ -547,6 +547,7 @@ reopen: ...@@ -547,6 +547,7 @@ reopen:
if (fscanf(file, "%d", &vm->pid) != 1) { if (fscanf(file, "%d", &vm->pid) != 1) {
errno = EINVAL; errno = EINVAL;
fclose(file);
goto cleanup; goto cleanup;
} }
...@@ -1040,6 +1041,7 @@ static int umlGetProcessInfo(unsigned long long *cpuTime, int pid) { ...@@ -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) { 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"); umlDebug("not enough arg");
fclose(pidinfo);
return -1; return -1;
} }
......
...@@ -1058,6 +1058,7 @@ int virFileReadPid(const char *dir, ...@@ -1058,6 +1058,7 @@ int virFileReadPid(const char *dir,
if (fscanf(file, "%d", pid) != 1) { if (fscanf(file, "%d", pid) != 1) {
rc = EINVAL; rc = EINVAL;
fclose(file);
goto cleanup; goto cleanup;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册