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.
virReportSystemError(errno,
_("cannot open path '%s'"),
pdom->home);
- goto cleanup;
+ return ret;
}
while ((direrr = virDirRead(dir, &ent, pdom->home)) > 0) {
}
cleanup:
- closedir(dir);
+ if (dir)
+ closedir(dir);
VIR_FREE(path);
return sg;
}
}
cleanup:
- closedir(dir);
+ if (dir)
+ closedir(dir);
VIR_FREE(path);
return name;
}