rbd: fix leak of fd on error when reading an entire file

CID 717100: Resource leak (RESOURCE_LEAK)
At (6): Handle variable "fd" going out of scope leaks the handle.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
This commit is contained in:
Josh Durgin 2012-09-24 15:29:13 -07:00
parent 5b22c1d68d
commit 55f72301ba

View File

@ -869,6 +869,7 @@ static int read_file(const char *filename, char *buf, size_t bufsize)
int r = safe_read(fd, buf, bufsize);
if (r < 0) {
cerr << "Warning: could not read " << filename << ": " << cpp_strerror(-r) << std::endl;
close(fd);
return r;
}