Do not call closedir with NULL argument

Only three other callers possibly call closedir on a NULL argument.
Even though these probably won't be used on FreeBSD where this crashes,
let's be nice and only call closedir on an actual directory stream.
This commit is contained in:
Ján Tomko 2014-06-23 08:58:27 +02:00
parent 9a2e523eba
commit 10af0a1973
2 changed files with 5 additions and 3 deletions

View File

@ -340,7 +340,7 @@ static int parallelsFindVmVolumes(virStoragePoolObjPtr pool,
virReportSystemError(errno,
_("cannot open path '%s'"),
pdom->home);
goto cleanup;
return ret;
}
while ((direrr = virDirRead(dir, &ent, pdom->home)) > 0) {

View File

@ -143,7 +143,8 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
}
cleanup:
closedir(dir);
if (dir)
closedir(dir);
VIR_FREE(path);
return sg;
}
@ -188,7 +189,8 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
}
cleanup:
closedir(dir);
if (dir)
closedir(dir);
VIR_FREE(path);
return name;
}