Blame SOURCES/0001-all-Fix-resource-leaks.patch

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