mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix memory leak in Json move assignment operator
* When move assignment is creates a cyclic ownership pattern memory was being leaked. This patch breaks the cycle. * Fixes: #2572
This commit is contained in:
committed by
Nik Bougalis
parent
156e8dae83
commit
157c066f2b
@@ -296,6 +296,17 @@ struct json_value_test : beast::unit_test::suite
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_leak()
|
||||
{
|
||||
// When run with the address sanitizer, this test confirms there is no
|
||||
// memory leak with the scenario below.
|
||||
Json::Value a;
|
||||
a[0u] = 1;
|
||||
a = std::move(a[0u]);
|
||||
pass();
|
||||
}
|
||||
|
||||
void run () override
|
||||
{
|
||||
test_bool ();
|
||||
@@ -306,6 +317,7 @@ struct json_value_test : beast::unit_test::suite
|
||||
test_comparisons ();
|
||||
test_compact ();
|
||||
test_nest_limits ();
|
||||
test_leak();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user