On 23.06.2014 09:06, Ján Tomko wrote:
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.
---
src/parallels/parallels_storage.c | 2 +-
src/util/virscsi.c | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c
index 4dbaed1..53bcfcb 100644
--- a/src/parallels/parallels_storage.c
+++ b/src/parallels/parallels_storage.c
@@ -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) {
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 9a0205f..9f5cf0d 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -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;
}
ACK
Michal