-
-
Notifications
You must be signed in to change notification settings - Fork 190
Closed
Description
The following code leads to a coredump:
jsoncons::ojson doc = jsoncons::ojson::parse(R"({"value":{"value":"long______________enough"}})");
jsoncons::jsonpath::json_replace(doc, "$..value",
[](const jsoncons::ojson& match) {
return jsoncons::ojson {"XXX"};
});
It works when the json_replace() overload that takes a value instead of a function is used:
jsoncons::ojson doc = jsoncons::ojson::parse(R"({"value":{"value":"long______________enough"}})");
jsoncons::jsonpath::json_replace(doc, "$..value", jsoncons::ojson {"XXX"});
Interestingly the coredump disappears when the inner "value" is rewriten first:
jsoncons::ojson doc = jsoncons::ojson::parse(R"({"value":{"value":"long______________enough"}})");
jsoncons::jsonpath::json_replace(doc, "$..value..value",
[](const jsoncons::ojson& match) {
return jsoncons::ojson {"XXX"};
});
std::cout << doc << '\n';
// now this works!
jsoncons::jsonpath::json_replace(doc, "$..value",
[](const jsoncons::ojson& match) {
return jsoncons::ojson {"XXX"};
});
- Compiler: g++ (GCC) 13.1.1 20230429
- Architecture: x64
- Operating system: Arch Linux
This bug was discovered in the release version 0.168.7 and reproduced on the current master