[all] Fix resource leaks

This commit is contained in:
Ming-Hung Tsai 2021-04-28 10:34:16 +08:00
parent b9df99fd6a
commit f7e4a8faa9
2 changed files with 4 additions and 2 deletions

View File

@ -155,8 +155,10 @@ file_utils::zero_superblock(std::string const &path)
throw runtime_error("out of memory");
memset(buffer, 0, SUPERBLOCK_SIZE);
if (::write(fd.fd_, buffer, SUPERBLOCK_SIZE) != SUPERBLOCK_SIZE)
if (::write(fd.fd_, buffer, SUPERBLOCK_SIZE) != SUPERBLOCK_SIZE) {
free(buffer);
throw runtime_error("couldn't zero superblock");
}
}
//----------------------------------------------------------------

View File

@ -62,7 +62,7 @@ chunk const &
cache_stream::get()
{
chunk_wrapper *w = new chunk_wrapper(*this);
return w->c_;
return w->c_; // wrapper will get freed by the put method
}
void