-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Labels
kind: bugsolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
Milestone
Description
Description
Throwing an exception in serializer function after the output json object is already initialized results in a memory leak (detected with both ASan and valgrind):
void adl_serializer<Foo>::to_json(json& j, Foo const& f) {
j["a"] = 42;
throw std::runtime_error("error");
}
Reproduction steps
Reproducer here: https://godbolt.org/z/dvorMExWh
Expected vs. actual results
Expected: no memory leak
Minimal code example
No response
Error messages
No response
Compiler and operating system
linux, clang 15, gcc 12.2
Library version
3.11.2, godbolt trunk, 7f72eed
Validation
- The bug also occurs if the latest version from the
develop
branch is used. - I can successfully compile and run the unit tests.
Metadata
Metadata
Assignees
Labels
kind: bugsolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation