From: Ján Tomko Date: Mon, 23 Jun 2014 06:58:27 +0000 (+0200) Subject: Do not call closedir with NULL argument X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=10af0a19736aa200170eec52a1e1befa73885a6c;p=libvirt.git 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. --- diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c index 4dbaed18ca..53bcfcb32b 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 9a0205ff88..9f5cf0daa1 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; }