From c0be4637221b0b8063decde786d37000ae5eaf00 Mon Sep 17 00:00:00 2001 From: ssaidala Date: Fri, 25 Oct 2024 13:01:19 +0530 Subject: [PATCH] Segmentation Fault observed while executing unit test "check_credentials" was erased and was trying to write inside freed memory leading to segmentation fault. --- test/common/src/utility.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/common/src/utility.cpp b/test/common/src/utility.cpp index cdf6db8a9..8933aee2a 100644 --- a/test/common/src/utility.cpp +++ b/test/common/src/utility.cpp @@ -120,7 +120,10 @@ utility::force_check_credentials( = security.get_child("check_credentials"); if (credentials.get_value().compare(_value)) { security.erase("check_credentials"); - credentials.put("check_credentials", _value); + // "check_credentials" was erased and was trying to write inside freed memory leading to segmentation fault. + boost::property_tree::ptree updatedCredentials; + updatedCredentials.put("check_credentials", _value); + security.add_child("security",updatedCredentials); } } catch(...) {}