You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider, say, the minimal input "a={\n" to toml::parse. We get a memory leak upon encountering the error Error while parsing inline table: expected key or closing '}', saw '\n'.
unexpected character found, so we run set_error_and_return_default("expected key or closing '}', saw '"sv, to_sv(*cp), "'"sv);
This leaves nobody to delete tab, and it is leaked. More importantly, this sort of pattern seems quite endemic to the parser code, so there are likely other places where leaks (or worse) happen.
The text was updated successfully, but these errors were encountered:
this sort of pattern seems quite endemic to the parser code
Originally it used std::unique_ptr but that caused binary bloat of about 10% or so on some implementations so it was an easy win to refactor it out. I thought I was pretty thorough in ensuring there weren't any leaks introduced, though I guess I'll find out.
Ah, can confirm that you're correct. Fewer leaks than you perhaps thought, though; one each on the error paths in parse_inline_table(), parse_array() and parse_key_value_pair_and_insert(). The actual impact of this was surprisingly low - 78 leaked objects from around 9100 generated during one run of the test suite. I was expecting it to be much worse!
Consider, say, the minimal input
"a={\n"
totoml::parse
. We get a memory leak upon encountering the errorError while parsing inline table: expected key or closing '}', saw '\n'
.Looking at where this happens,
parser::parse_inline_table
, it is quite clear how this happens:auto tab = new table{};
set_error_and_return_default("expected key or closing '}', saw '"sv, to_sv(*cp), "'"sv);
This leaves nobody to delete
tab
, and it is leaked. More importantly, this sort of pattern seems quite endemic to the parser code, so there are likely other places where leaks (or worse) happen.The text was updated successfully, but these errors were encountered: