mirror of
https://github.com/libvirt/libvirt.git
synced 2026-08-09 12:38:27 -05:00
Avoid some potential FILE * leaks
* qemud/qemud.c src/cgroup.c src/uml_driver.c src/util.c: close some potential FILE * leaks Daniel
This commit is contained in:
+3
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1058,6 +1058,7 @@ int virFileReadPid(const char *dir,
|
||||
|
||||
if (fscanf(file, "%d", pid) != 1) {
|
||||
rc = EINVAL;
|
||||
fclose(file);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user