|
|
5a5b1b |
From 48676b9f1aac63f8a30ed8061b6e719929b82c98 Mon Sep 17 00:00:00 2001
|
|
|
5a5b1b |
From: Ming-Hung Tsai <mtsai@redhat.com>
|
|
|
5a5b1b |
Date: Wed, 28 Apr 2021 10:34:16 +0800
|
|
|
5a5b1b |
Subject: [PATCH 01/10] [all] Fix resource leaks
|
|
|
5a5b1b |
|
|
|
5a5b1b |
---
|
|
|
5a5b1b |
base/file_utils.cc | 4 +++-
|
|
|
5a5b1b |
thin-provisioning/cache_stream.cc | 2 +-
|
|
|
5a5b1b |
2 files changed, 4 insertions(+), 2 deletions(-)
|
|
|
5a5b1b |
|
|
|
5a5b1b |
diff --git a/base/file_utils.cc b/base/file_utils.cc
|
|
|
5a5b1b |
index e4f3722..8253660 100644
|
|
|
5a5b1b |
--- a/base/file_utils.cc
|
|
|
5a5b1b |
+++ b/base/file_utils.cc
|
|
|
5a5b1b |
@@ -155,8 +155,10 @@ file_utils::zero_superblock(std::string const &path)
|
|
|
5a5b1b |
throw runtime_error("out of memory");
|
|
|
5a5b1b |
|
|
|
5a5b1b |
memset(buffer, 0, SUPERBLOCK_SIZE);
|
|
|
5a5b1b |
- if (::write(fd.fd_, buffer, SUPERBLOCK_SIZE) != SUPERBLOCK_SIZE)
|
|
|
5a5b1b |
+ if (::write(fd.fd_, buffer, SUPERBLOCK_SIZE) != SUPERBLOCK_SIZE) {
|
|
|
5a5b1b |
+ free(buffer);
|
|
|
5a5b1b |
throw runtime_error("couldn't zero superblock");
|
|
|
5a5b1b |
+ }
|
|
|
5a5b1b |
}
|
|
|
5a5b1b |
|
|
|
5a5b1b |
//----------------------------------------------------------------
|
|
|
5a5b1b |
diff --git a/thin-provisioning/cache_stream.cc b/thin-provisioning/cache_stream.cc
|
|
|
5a5b1b |
index 002b6ba..73b01b4 100644
|
|
|
5a5b1b |
--- a/thin-provisioning/cache_stream.cc
|
|
|
5a5b1b |
+++ b/thin-provisioning/cache_stream.cc
|
|
|
5a5b1b |
@@ -62,7 +62,7 @@ chunk const &
|
|
|
5a5b1b |
cache_stream::get()
|
|
|
5a5b1b |
{
|
|
|
5a5b1b |
chunk_wrapper *w = new chunk_wrapper(*this);
|
|
|
5a5b1b |
- return w->c_;
|
|
|
5a5b1b |
+ return w->c_; // wrapper will get freed by the put method
|
|
|
5a5b1b |
}
|
|
|
5a5b1b |
|
|
|
5a5b1b |
void
|
|
|
5a5b1b |
--
|
|
|
5a5b1b |
1.8.3.1
|
|
|
5a5b1b |
|