From 1f5d46ceac30d3ad3fe5c4f623385e79d459d6a2 Mon Sep 17 00:00:00 2001 From: chenzihan Date: Mon, 25 Apr 2022 11:07:25 +0800 Subject: [PATCH 1/2] Signed-off-by: chenzihan fix:codex --- services/applypatch/block_set.cpp | 6 ++++++ services/include/applypatch/block_set.h | 9 +++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/services/applypatch/block_set.cpp b/services/applypatch/block_set.cpp index b267cfb7..00971141 100644 --- a/services/applypatch/block_set.cpp +++ b/services/applypatch/block_set.cpp @@ -43,6 +43,12 @@ BlockSet::BlockSet(std::vector &&pairs) } } +BlockSet::~BlockSet() +{ + blockSize_ = 0; + blocks_.clear(); +} + bool BlockSet::CheckReliablePair(BlockPair pair) { UPDATER_ERROR_CHECK(pair.first < pair.second, "Invalid number of block size", return false); diff --git a/services/include/applypatch/block_set.h b/services/include/applypatch/block_set.h index a59f3956..6ee4bdb7 100644 --- a/services/include/applypatch/block_set.h +++ b/services/include/applypatch/block_set.h @@ -35,12 +35,9 @@ class Command; class BlockSet { public: - BlockSet() - { - blockSize_ = 0; - } - explicit BlockSet(std::vector &&pairs); + + ~BlockSet(); // Insert block to set after parsing from a string type or vector type bool ParserAndInsert(const std::string &blockStr); @@ -96,7 +93,7 @@ public: // write data to block size_t WriteDataToBlock(int fd, std::vector &buffer); protected: - size_t blockSize_; + size_t blockSize_ = 0; std::vector blocks_; private: void PushBack(BlockPair block_pair); -- Gitee From 9135dee2e946fb130524116a0de95f29ccdc7991 Mon Sep 17 00:00:00 2001 From: chenzihan Date: Mon, 25 Apr 2022 11:07:25 +0800 Subject: [PATCH 2/2] Signed-off-by: chenzihan fix:codex --- services/applypatch/block_set.cpp | 6 ++++++ services/include/applypatch/block_set.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/services/applypatch/block_set.cpp b/services/applypatch/block_set.cpp index b267cfb7..00971141 100644 --- a/services/applypatch/block_set.cpp +++ b/services/applypatch/block_set.cpp @@ -43,6 +43,12 @@ BlockSet::BlockSet(std::vector &&pairs) } } +BlockSet::~BlockSet() +{ + blockSize_ = 0; + blocks_.clear(); +} + bool BlockSet::CheckReliablePair(BlockPair pair) { UPDATER_ERROR_CHECK(pair.first < pair.second, "Invalid number of block size", return false); diff --git a/services/include/applypatch/block_set.h b/services/include/applypatch/block_set.h index a59f3956..2059cc66 100644 --- a/services/include/applypatch/block_set.h +++ b/services/include/applypatch/block_set.h @@ -41,6 +41,8 @@ public: } explicit BlockSet(std::vector &&pairs); + + ~BlockSet(); // Insert block to set after parsing from a string type or vector type bool ParserAndInsert(const std::string &blockStr); -- Gitee