From 592afc6f0ab7d2c2f15688a254ba4174c73bec63 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Thu, 14 Aug 2025 13:54:16 +0200 Subject: [PATCH] Avoid dangling pointer in TrexRpcCommand parse_object(). g++ (Debian 14.2.0-19) 14.2.0 fails with error: dangling pointer to an unnamed temporary may be used. Create a Json::Value instance initialized with Json::nullValue that has longer life time than the Json::Value object returned by parse_object(). Signed-off-by: Alexander Bluhm --- src/stx/stl/trex_stl_rpc_cmds.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stx/stl/trex_stl_rpc_cmds.cpp b/src/stx/stl/trex_stl_rpc_cmds.cpp index 4581bcb0e2..c202bc3270 100644 --- a/src/stx/stl/trex_stl_rpc_cmds.cpp +++ b/src/stx/stl/trex_stl_rpc_cmds.cpp @@ -1896,7 +1896,8 @@ TrexRpcCmdUpdateTaggedPktGroupTags::_run(const Json::Value ¶ms, Json::Value std::string type = parse_string(itr, "type", result, ""); uint16_t tag_id = parse_uint16(itr, "tag_id", result); - const Json::Value& value = parse_object(itr, "value", result, Json::nullValue); + const Json::Value def(Json::nullValue); + const Json::Value& value = parse_object(itr, "value", result, def); if (tag_id >= num_tags) { err_msg = "Tag Id " + std::to_string(tag_id) + " greater than num of tags " + std::to_string(num_tags);