From 87154a3ed085e442531fe36a4f5a9375c2d8e43d Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Thu, 19 Feb 2026 18:30:14 +0900 Subject: [PATCH] test: guarantee proper lifetime for temporary Rules object: (#4917) * Commit 01c37fe introduced a change to the STTx unit test where a local "defaultRules" object was created with a temporary inline "presets" value provided to the ctor. Rules::Impl stores a const ref to the presets provided to the ctor. This particular call provided an inline temp variable, which goes out of scope as soon as the object is created. On Windows, attempting to use the presets (e.g. via the enabled() function) causes an access violation, which crashes the test run. * An audit of the code indicates that all other instances of Rules use the Application's config.features list, which will have a sufficient lifetime. --- src/test/protocol/STTx_test.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/protocol/STTx_test.cpp b/src/test/protocol/STTx_test.cpp index 395672666..24bf71961 100644 --- a/src/test/protocol/STTx_test.cpp +++ b/src/test/protocol/STTx_test.cpp @@ -1591,7 +1591,11 @@ public: }); j.sign(keypair.first, keypair.second); - Rules defaultRules{{}}; + // Rules store a reference to the presets. Create a local to guarantee + // proper lifetime. + std::unordered_set> const presets; + Rules const defaultRules{presets}; + BEAST_EXPECT(!defaultRules.enabled(featureExpandedSignerList)); unexpected( !j.checkSign(STTx::RequireFullyCanonicalSig::yes, defaultRules),