Fix memory leak (#124)

Fix leak occuring when parsing of a value throws an exception.
This commit is contained in:
Robin Sommer 2021-12-04 09:21:19 +01:00 committed by GitHub
parent 47216c8a73
commit e557e41b05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -2474,7 +2474,8 @@ TOML_IMPL_NAMESPACE_START
// get the value // get the value
if (is_value_terminator(*cp)) if (is_value_terminator(*cp))
set_error_and_return_default("expected value, saw '"sv, to_sv(*cp), "'"sv); set_error_and_return_default("expected value, saw '"sv, to_sv(*cp), "'"sv);
return { std::move(key), node_ptr{ parse_value() } }; auto value = parse_value();
return { std::move(key), node_ptr{ value } };
} }
TOML_NODISCARD TOML_NODISCARD

View File

@ -11889,7 +11889,8 @@ TOML_IMPL_NAMESPACE_START
// get the value // get the value
if (is_value_terminator(*cp)) if (is_value_terminator(*cp))
set_error_and_return_default("expected value, saw '"sv, to_sv(*cp), "'"sv); set_error_and_return_default("expected value, saw '"sv, to_sv(*cp), "'"sv);
return { std::move(key), node_ptr{ parse_value() } }; auto value = parse_value();
return { std::move(key), node_ptr{ value } };
} }
TOML_NODISCARD TOML_NODISCARD