Skip to content

Commit fe0ac89

Browse files
committed
fixed parser memory leak (fixes #64)
also: - build/infra improvements - updated submodules - updated conformance tests - misc code review/refactors - library version bump - TOML version bump
1 parent aca6327 commit fe0ac89

File tree

62 files changed

+901
-300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+901
-300
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Releases](https://img.shields.io/github/v/release/marzer/tomlplusplus?style=flat-square)](https://github.com/marzer/tomlplusplus/releases)
33
[![C++17](docs/badge-C++17.svg)][cpp_compilers]
44
[![C++20](docs/badge-C++20.svg)][cpp_compilers]
5-
[![TOML](docs/badge-TOML.svg)][v1.0.0-rc.2]
5+
[![TOML](docs/badge-TOML.svg)][v1.0.0-rc.3]
66
[![MIT license](docs/badge-license-MIT.svg)](./LICENSE)
77
[![CircleCI](https://img.shields.io/circleci/build/github/marzer/tomlplusplus?label=circle%20ci&logo=circleci&logoColor=white&style=flat-square)](https://circleci.com/gh/marzer/tomlplusplus)
88
[![Mentioned in Awesome C++](docs/badge-awesome.svg)](https://github.com/fffaraz/awesome-cpp)
@@ -19,7 +19,7 @@
1919
# Library features
2020

2121
- Header-only
22-
- Supports the latest [TOML] release ([v1.0.0-rc.2]), plus optional support for some [unreleased TOML language features]
22+
- Supports the latest [TOML] release ([v1.0.0-rc.3]), plus optional support for some [unreleased TOML language features]
2323
- C++17 (plus some C++20 features where available, e.g. experimental support for char8_t strings)
2424
- Proper UTF-8 handling (incl. BOM)
2525
- Works with or without exceptions
@@ -165,12 +165,13 @@ defines `TOML_LANG_MAJOR`, `TOML_LANG_MINOR` and `TOML_LANG_PATCH`.
165165
166166
> ℹ _`#define TOML_UNRELEASED_FEATURES 1` to enable these features (see [Configuration](#Configuration))._
167167
168-
### 🔹 **TOML v1.0.0-rc.2:**
168+
### 🔹 **TOML v1.0.0-rc.3:**
169169
All features supported, including:
170170
- [#356]: Allow leading zeros in the exponent part of a float
171171
- [#567]: Control characters are not permitted in comments
172172
- [#571]: Allow raw tabs inside strings
173173
- [#665]: Make arrays heterogeneous
174+
- [#766]: Allow comments before commas in arrays
174175
175176
### 🔹 **TOML v0.5.0:**
176177
All features supported.
@@ -202,6 +203,7 @@ UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's '[
202203
- **[@Reedbeta](https://github.com/Reedbeta)** - Fixed a bug and added additional Visual Studio debugger native visualizers
203204
- **[@shdnx](https://github.com/shdnx)** - Fixed a bug on GCC 8.2.0 and some meson config issues
204205
- **[@sobczyk](https://github.com/sobczyk)** - Reported some bugs
206+
- **[@sneves](https://github.com/sneves)** - Reported a bug
205207
- **[@traversaro](https://github.com/traversaro)** - Added vcpkg support and reported a bunch of bugs
206208
- **[@ximion](https://github.com/ximion)** - Added support for installation with meson
207209
- **[@whiterabbit963](https://github.com/whiterabbit963)** - Fixed a bug with value_or conversions
@@ -227,7 +229,7 @@ though you're welcome to reach out via other means. In order of likely response
227229
[TOML]: https://toml.io/
228230
[TOML master]: https://github.com/toml-lang/toml/blob/master/README.md
229231
[TOML issues list]: https://github.com/toml-lang/toml/issues
230-
[v1.0.0-rc.2]: https://toml.io/en/v1.0.0-rc.2
232+
[v1.0.0-rc.3]: https://toml.io/en/v1.0.0-rc.3
231233
[CONTRIBUTING]: ./CONTRIBUTING.md
232234
[LICENSE]: ./LICENSE
233235
[Flexible and Economical UTF-8 Decoder]: http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
@@ -246,6 +248,7 @@ though you're welcome to reach out via other means. In order of likely response
246248
[#671]: https://github.com/toml-lang/toml/issues/671
247249
[#687]: https://github.com/toml-lang/toml/issues/687
248250
[#709]: https://github.com/toml-lang/toml/pull/709
251+
[#766]: https://github.com/toml-lang/toml/issues/766
249252
[LICENSE-utf8-decoder]: ./LICENSE-utf8-decoder
250253
[something better than std::optional]: https://github.com/TartanLlama/optional
251254
[m.css]: https://mcss.mosra.cz/documentation/doxygen

docs/badge-TOML.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/main_page.dox

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//////////////////////////////////////////////////////////////////////
77
///
88
/// \section mainpage-features Features
9-
/// - Supports the latest [TOML](https://toml.io/) release ([v1.0.0-rc.2](https://toml.io/en/v1.0.0-rc.2)), plus
9+
/// - Supports the latest [TOML](https://toml.io/) release ([v1.0.0-rc.3](https://toml.io/en/v1.0.0-rc.3)), plus
1010
/// optional support for some unreleased TOML features
1111
/// - Supports serializing to JSON
1212
/// - Proper UTF-8 handling (incl. BOM)
@@ -316,7 +316,7 @@
316316
/// auto tbl = toml::table{{
317317
/// { "lib", "toml++" },
318318
/// { "cpp", toml::array{ 17, 20, "and beyond" } },
319-
/// { "toml", toml::array{ "1.0.0-rc.2", "and beyond" } },
319+
/// { "toml", toml::array{ "1.0.0-rc.3", "and beyond" } },
320320
/// { "repo", "https://github.com/marzer/tomlplusplus/" },
321321
/// { "author", toml::table{{
322322
/// { "name", "Mark Gillard" },
@@ -343,7 +343,7 @@
343343
/// cpp = [ 17, 20, 'and beyond' ]
344344
/// lib = 'toml++'
345345
/// repo = 'https://github.com/marzer/tomlplusplus/'
346-
/// toml = [ '1.0.0-rc.2', 'and beyond' ]
346+
/// toml = [ '1.0.0-rc.3', 'and beyond' ]
347347
///
348348
/// [author]
349349
/// github = 'https://github.com/marzer'
@@ -366,7 +366,7 @@
366366
/// "lib" : "toml++",
367367
/// "repo" : "https://github.com/marzer/tomlplusplus/",
368368
/// "toml" : [
369-
/// "1.0.0-rc.2",
369+
/// "1.0.0-rc.3",
370370
/// "and beyond"
371371
/// ]
372372
/// }

docs/muu.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pre.m-code .c1
162162
}
163163

164164
/* int and float literals */
165+
pre.m-code .mb,
165166
pre.m-code .mi,
166167
pre.m-code .mf,
167168
pre.m-code .mh

extern/Catch2

Submodule Catch2 updated 52 files

extern/mcss

Submodule mcss updated 64 files

extern/toml-test

include/toml++/toml.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ TOML_POP_WARNINGS // TOML_DISABLE_SPAM_WARNINGS
108108
#undef TOML_LANG_HIGHER_THAN
109109
#undef TOML_LANG_UNRELEASED
110110
#undef TOML_LAUNDER
111+
#undef TOML_LIFETIME_HOOKS
111112
#undef TOML_LIKELY
112113
#undef TOML_MAKE_BITOPS
113114
#undef TOML_MAKE_VERSION

include/toml++/toml_array.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ TOML_NAMESPACE_START
315315
elements.emplace_back(impl::make_node(std::forward<T>(val)));
316316
}
317317

318+
#if TOML_LIFETIME_HOOKS
319+
void lh_ctor() noexcept;
320+
void lh_dtor() noexcept;
321+
#endif
322+
318323
public:
319324

320325
using value_type = node;
@@ -346,6 +351,9 @@ TOML_NAMESPACE_START
346351
/// \brief Move-assignment operator.
347352
array& operator= (array&& rhs) noexcept;
348353

354+
/// \brief Destructor.
355+
~array() noexcept override;
356+
349357
/// \brief Constructs an array with one or more initial elements.
350358
///
351359
/// \detail \cpp
@@ -395,8 +403,11 @@ TOML_NAMESPACE_START
395403
...
396404
);
397405
}
398-
}
399406

407+
#if TOML_LIFETIME_HOOKS
408+
lh_ctor();
409+
#endif
410+
}
400411

401412
[[nodiscard]] node_type type() const noexcept override;
402413
[[nodiscard]] bool is_table() const noexcept override;

include/toml++/toml_array.hpp

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,29 @@
1515

1616
TOML_NAMESPACE_START
1717
{
18+
#if TOML_LIFETIME_HOOKS
19+
20+
TOML_EXTERNAL_LINKAGE
21+
void array::lh_ctor() noexcept
22+
{
23+
TOML_ARRAY_CREATED;
24+
}
25+
1826
TOML_EXTERNAL_LINKAGE
19-
array::array() noexcept = default;
27+
void array::lh_dtor() noexcept
28+
{
29+
TOML_ARRAY_DESTROYED;
30+
}
31+
32+
#endif
33+
34+
TOML_EXTERNAL_LINKAGE
35+
array::array() noexcept
36+
{
37+
#if TOML_LIFETIME_HOOKS
38+
lh_ctor();
39+
#endif
40+
}
2041

2142
TOML_EXTERNAL_LINKAGE
2243
array::array(const array& other) noexcept
@@ -25,13 +46,21 @@ TOML_NAMESPACE_START
2546
elements.reserve(other.elements.size());
2647
for (const auto& elem : other)
2748
elements.emplace_back(impl::make_node(elem));
49+
50+
#if TOML_LIFETIME_HOOKS
51+
lh_ctor();
52+
#endif
2853
}
2954

3055
TOML_EXTERNAL_LINKAGE
3156
array::array(array&& other) noexcept
3257
: node{ std::move(other) },
3358
elements{ std::move(other.elements) }
34-
{}
59+
{
60+
#if TOML_LIFETIME_HOOKS
61+
lh_ctor();
62+
#endif
63+
}
3564

3665
TOML_EXTERNAL_LINKAGE
3766
array& array::operator= (const array& rhs) noexcept
@@ -58,6 +87,14 @@ TOML_NAMESPACE_START
5887
return *this;
5988
}
6089

90+
TOML_EXTERNAL_LINKAGE
91+
array::~array() noexcept
92+
{
93+
#if TOML_LIFETIME_HOOKS
94+
lh_dtor();
95+
#endif
96+
}
97+
6198
TOML_EXTERNAL_LINKAGE
6299
void array::preinsertion_resize(size_t idx, size_t count) noexcept
63100
{

0 commit comments

Comments
 (0)