Skip to content

Commit

Permalink
Fix memory leak (#124)
Browse files Browse the repository at this point in the history
Fix leak occuring when parsing of a value throws an exception.
  • Loading branch information
rsmmr authored Dec 4, 2021
1 parent 47216c8 commit e557e41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/toml++/impl/parser_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2474,7 +2474,8 @@ TOML_IMPL_NAMESPACE_START
// get the value
if (is_value_terminator(*cp))
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
Expand Down
3 changes: 2 additions & 1 deletion toml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11889,7 +11889,8 @@ TOML_IMPL_NAMESPACE_START
// get the value
if (is_value_terminator(*cp))
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
Expand Down

0 comments on commit e557e41

Please sign in to comment.