This is an automated email from the ASF dual-hosted git repository.
wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 86427a50 Fix possible segment fault in delete_stats() of
MultiDimension. (#2237) (#2238)
86427a50 is described below
commit 86427a50eafd731495973c4bb5f4b865a523107d
Author: Ketor <[email protected]>
AuthorDate: Mon May 8 09:47:55 2023 +0800
Fix possible segment fault in delete_stats() of MultiDimension. (#2237)
(#2238)
Signed-off-by: Ketor <[email protected]>
---
src/bvar/multi_dimension_inl.h | 1 +
test/bvar_multi_dimension_unittest.cpp | 2 ++
2 files changed, 3 insertions(+)
diff --git a/src/bvar/multi_dimension_inl.h b/src/bvar/multi_dimension_inl.h
index 9e282dfa..0ab960fe 100644
--- a/src/bvar/multi_dimension_inl.h
+++ b/src/bvar/multi_dimension_inl.h
@@ -118,6 +118,7 @@ void MultiDimension<T>::delete_stats() {
// then traversal tmp_map and delete bvar object,
// which can prevent the bvar object from being deleted twice.
MetricMap tmp_map;
+ CHECK_EQ(0, tmp_map.init(8192, 80));
auto clear_fn = [&tmp_map](MetricMap& map) {
if (!tmp_map.empty()) {
tmp_map.clear();
diff --git a/test/bvar_multi_dimension_unittest.cpp
b/test/bvar_multi_dimension_unittest.cpp
index b30f8245..ebc048b1 100644
--- a/test/bvar_multi_dimension_unittest.cpp
+++ b/test/bvar_multi_dimension_unittest.cpp
@@ -355,6 +355,8 @@ TEST_F(MultiDimensionTest, stats) {
ASSERT_FALSE(my_madder.has_stats(labels_value2));
ASSERT_FALSE(my_madder.has_stats(labels_value3));
ASSERT_FALSE(my_madder.has_stats(labels_value4));
+ bvar::Adder<int> *adder5 = my_madder.get_stats(labels_value1);
+ ASSERT_TRUE(adder5);
}
TEST_F(MultiDimensionTest, get_description) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]