Skip to content

Commit

Permalink
fixed parser memory leak (fixes #64)
Browse files Browse the repository at this point in the history
also:
- build/infra improvements
- updated submodules
- updated conformance tests
- misc code review/refactors
- library version bump
- TOML version bump
  • Loading branch information
marzer committed Oct 9, 2020
1 parent aca6327 commit fe0ac89
Show file tree
Hide file tree
Showing 62 changed files with 901 additions and 300 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Releases](https://img.shields.io/github/v/release/marzer/tomlplusplus?style=flat-square)](https://github.com/marzer/tomlplusplus/releases)
[![C++17](docs/badge-C++17.svg)][cpp_compilers]
[![C++20](docs/badge-C++20.svg)][cpp_compilers]
[![TOML](docs/badge-TOML.svg)][v1.0.0-rc.2]
[![TOML](docs/badge-TOML.svg)][v1.0.0-rc.3]
[![MIT license](docs/badge-license-MIT.svg)](./LICENSE)
[![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)
[![Mentioned in Awesome C++](docs/badge-awesome.svg)](https://github.com/fffaraz/awesome-cpp)
Expand All @@ -19,7 +19,7 @@
# Library features

- Header-only
- Supports the latest [TOML] release ([v1.0.0-rc.2]), plus optional support for some [unreleased TOML language features]
- Supports the latest [TOML] release ([v1.0.0-rc.3]), plus optional support for some [unreleased TOML language features]
- C++17 (plus some C++20 features where available, e.g. experimental support for char8_t strings)
- Proper UTF-8 handling (incl. BOM)
- Works with or without exceptions
Expand Down Expand Up @@ -165,12 +165,13 @@ defines `TOML_LANG_MAJOR`, `TOML_LANG_MINOR` and `TOML_LANG_PATCH`.
> ℹ _`#define TOML_UNRELEASED_FEATURES 1` to enable these features (see [Configuration](#Configuration))._
### 🔹 **TOML v1.0.0-rc.2:**
### 🔹 **TOML v1.0.0-rc.3:**
All features supported, including:
- [#356]: Allow leading zeros in the exponent part of a float
- [#567]: Control characters are not permitted in comments
- [#571]: Allow raw tabs inside strings
- [#665]: Make arrays heterogeneous
- [#766]: Allow comments before commas in arrays
### 🔹 **TOML v0.5.0:**
All features supported.
Expand Down Expand Up @@ -202,6 +203,7 @@ UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's '[
- **[@Reedbeta](https://github.com/Reedbeta)** - Fixed a bug and added additional Visual Studio debugger native visualizers
- **[@shdnx](https://github.com/shdnx)** - Fixed a bug on GCC 8.2.0 and some meson config issues
- **[@sobczyk](https://github.com/sobczyk)** - Reported some bugs
- **[@sneves](https://github.com/sneves)** - Reported a bug
- **[@traversaro](https://github.com/traversaro)** - Added vcpkg support and reported a bunch of bugs
- **[@ximion](https://github.com/ximion)** - Added support for installation with meson
- **[@whiterabbit963](https://github.com/whiterabbit963)** - Fixed a bug with value_or conversions
Expand All @@ -227,7 +229,7 @@ though you're welcome to reach out via other means. In order of likely response
[TOML]: https://toml.io/
[TOML master]: https://github.com/toml-lang/toml/blob/master/README.md
[TOML issues list]: https://github.com/toml-lang/toml/issues
[v1.0.0-rc.2]: https://toml.io/en/v1.0.0-rc.2
[v1.0.0-rc.3]: https://toml.io/en/v1.0.0-rc.3
[CONTRIBUTING]: ./CONTRIBUTING.md
[LICENSE]: ./LICENSE
[Flexible and Economical UTF-8 Decoder]: http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
Expand All @@ -246,6 +248,7 @@ though you're welcome to reach out via other means. In order of likely response
[#671]: https://github.com/toml-lang/toml/issues/671
[#687]: https://github.com/toml-lang/toml/issues/687
[#709]: https://github.com/toml-lang/toml/pull/709
[#766]: https://github.com/toml-lang/toml/issues/766
[LICENSE-utf8-decoder]: ./LICENSE-utf8-decoder
[something better than std::optional]: https://github.com/TartanLlama/optional
[m.css]: https://mcss.mosra.cz/documentation/doxygen
2 changes: 1 addition & 1 deletion docs/badge-TOML.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/main_page.dox
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//////////////////////////////////////////////////////////////////////
///
/// \section mainpage-features Features
/// - Supports the latest [TOML](https://toml.io/) release ([v1.0.0-rc.2](https://toml.io/en/v1.0.0-rc.2)), plus
/// - Supports the latest [TOML](https://toml.io/) release ([v1.0.0-rc.3](https://toml.io/en/v1.0.0-rc.3)), plus
/// optional support for some unreleased TOML features
/// - Supports serializing to JSON
/// - Proper UTF-8 handling (incl. BOM)
Expand Down Expand Up @@ -316,7 +316,7 @@
/// auto tbl = toml::table{{
/// { "lib", "toml++" },
/// { "cpp", toml::array{ 17, 20, "and beyond" } },
/// { "toml", toml::array{ "1.0.0-rc.2", "and beyond" } },
/// { "toml", toml::array{ "1.0.0-rc.3", "and beyond" } },
/// { "repo", "https://github.com/marzer/tomlplusplus/" },
/// { "author", toml::table{{
/// { "name", "Mark Gillard" },
Expand All @@ -343,7 +343,7 @@
/// cpp = [ 17, 20, 'and beyond' ]
/// lib = 'toml++'
/// repo = 'https://github.com/marzer/tomlplusplus/'
/// toml = [ '1.0.0-rc.2', 'and beyond' ]
/// toml = [ '1.0.0-rc.3', 'and beyond' ]
///
/// [author]
/// github = 'https://github.com/marzer'
Expand All @@ -366,7 +366,7 @@
/// "lib" : "toml++",
/// "repo" : "https://github.com/marzer/tomlplusplus/",
/// "toml" : [
/// "1.0.0-rc.2",
/// "1.0.0-rc.3",
/// "and beyond"
/// ]
/// }
Expand Down
1 change: 1 addition & 0 deletions docs/muu.css
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ pre.m-code .c1
}

/* int and float literals */
pre.m-code .mb,
pre.m-code .mi,
pre.m-code .mf,
pre.m-code .mh
Expand Down
2 changes: 1 addition & 1 deletion extern/Catch2
Submodule Catch2 updated 52 files
+1 −1 .github/FUNDING.yml
+12 −11 CMakeLists.txt
+2 −2 README.md
+32 −2 contrib/Catch.cmake
+51 −0 contrib/CatchAddTests.cmake
+21 −8 contrib/ParseAndAddCatchTests.cmake
+44 −0 docs/cmake-integration.md
+10 −0 docs/command-line.md
+139 −106 docs/contributing.md
+63 −17 docs/generators.md
+75 −0 docs/release-notes.md
+3 −1 examples/301-Gen-MapTypeConversion.cpp
+1 −1 include/catch.hpp
+3 −0 include/internal/catch_commandline.cpp
+6 −14 include/internal/catch_compiler_capabilities.h
+1 −0 include/internal/catch_config.cpp
+2 −0 include/internal/catch_config.hpp
+44 −0 include/internal/catch_config_uncaught_exceptions.hpp
+5 −1 include/internal/catch_debugger.h
+1 −0 include/internal/catch_interfaces_config.h
+1 −1 include/internal/catch_output_redirect.cpp
+23 −4 include/internal/catch_run_context.cpp
+3 −3 include/internal/catch_test_case_registry_impl.cpp
+2 −1 include/internal/catch_test_case_tracker.cpp
+4 −1 include/internal/catch_test_case_tracker.h
+6 −6 include/internal/catch_test_registry.h
+2 −2 include/internal/catch_tostring.h
+2 −0 include/internal/catch_uncaught_exceptions.cpp
+1 −1 include/internal/catch_version.cpp
+11 −0 include/reporters/catch_reporter_bases.cpp
+4 −1 include/reporters/catch_reporter_bases.hpp
+3 −6 include/reporters/catch_reporter_compact.cpp
+0 −2 include/reporters/catch_reporter_compact.h
+3 −2 include/reporters/catch_reporter_console.cpp
+12 −11 include/reporters/catch_reporter_tap.hpp
+8 −0 include/reporters/catch_reporter_xml.cpp
+2 −0 projects/CMakeLists.txt
+34 −0 projects/ExtraTests/CMakeLists.txt
+43 −0 projects/SelfTest/Baselines/compact.sw.approved.txt
+2 −2 projects/SelfTest/Baselines/console.std.approved.txt
+431 −2 projects/SelfTest/Baselines/console.sw.approved.txt
+420 −2 projects/SelfTest/Baselines/console.swa4.approved.txt
+11 −1 projects/SelfTest/Baselines/junit.sw.approved.txt
+10 −0 projects/SelfTest/Baselines/sonarqube.sw.approved.txt
+351 −2 projects/SelfTest/Baselines/xml.sw.approved.txt
+47 −0 projects/SelfTest/IntrospectiveTests/PartTracker.tests.cpp
+11 −0 projects/SelfTest/IntrospectiveTests/ToString.tests.cpp
+23 −0 projects/SelfTest/TimingTests/Sleep.tests.cpp
+1 −0 projects/SelfTest/UsageTests/Generators.tests.cpp
+2 −2 projects/TestScripts/testRandomOrder.py
+201 −82 single_include/catch2/catch.hpp
+12 −11 single_include/catch2/catch_reporter_tap.hpp
2 changes: 1 addition & 1 deletion extern/mcss
Submodule mcss updated 64 files
+3 −2 CREDITS.rst
+3 −0 css/m-components.css
+4 −1 css/m-dark+documentation.compiled.css
+3 −0 css/m-dark.compiled.css
+1 −1 css/m-dark.documentation.compiled.css
+1 −1 css/m-documentation.css
+4 −1 css/m-light+documentation.compiled.css
+3 −0 css/m-light.compiled.css
+1 −1 css/m-light.documentation.compiled.css
+44 −32 doc/documentation/python.rst
+1 −1 doc/plugins/metadata.rst
+22 −4 documentation/python.py
+3 −1 documentation/search.js
+1 −1 documentation/templates/doxygen/annotated.html
+1 −1 documentation/templates/doxygen/files.html
+1 −1 documentation/templates/doxygen/modules.html
+1 −1 documentation/templates/doxygen/namespaces.html
+1 −1 documentation/templates/doxygen/pages.html
+1 −1 documentation/templates/python/classes.html
+1 −1 documentation/templates/python/modules.html
+1 −1 documentation/templates/python/pages.html
+1 −1 documentation/test_doxygen/compound_deprecated/annotated.html
+1 −1 documentation/test_doxygen/compound_deprecated/files.html
+1 −1 documentation/test_doxygen/compound_deprecated/modules.html
+1 −1 documentation/test_doxygen/compound_deprecated/namespaces.html
+1 −1 documentation/test_doxygen/compound_deprecated/pages.html
+1 −1 documentation/test_doxygen/compound_filename_case/pages.html
+1 −1 documentation/test_doxygen/compound_inline_namespace/annotated.html
+1 −1 documentation/test_doxygen/compound_inline_namespace/namespaces.html
+1 −1 documentation/test_doxygen/compound_listing/annotated.html
+1 −1 documentation/test_doxygen/compound_listing/files.html
+1 −1 documentation/test_doxygen/compound_listing/namespaces.html
+1 −1 documentation/test_doxygen/compound_listing/pages.html
+1 −1 documentation/test_doxygen/compound_modules/modules.html
+1 −1 documentation/test_doxygen/compound_since/annotated.html
+1 −1 documentation/test_doxygen/compound_since/files.html
+1 −1 documentation/test_doxygen/compound_since/modules.html
+1 −1 documentation/test_doxygen/compound_since/namespaces.html
+1 −1 documentation/test_doxygen/compound_since/pages.html
+1 −1 documentation/test_doxygen/cpp_derived/annotated.html
+1 −1 documentation/test_doxygen/layout/pages.html
+1 −1 documentation/test_doxygen/page_brief/pages.html
+1 −1 documentation/test_doxygen/page_empty_page/pages.html
+1 −1 documentation/test_doxygen/page_order/pages.html
+1 −1 documentation/test_doxygen/page_subpage_of_index/pages.html
+1 −1 documentation/test_doxygen/undocumented/annotated.html
+1 −1 documentation/test_doxygen/undocumented/files.html
+1 −1 documentation/test_python/content/classes.html
+10 −0 documentation/test_python/inspect_annotations/inspect_annotations.html
+13 −6 documentation/test_python/inspect_annotations/inspect_annotations.py
+1 −1 documentation/test_python/inspect_string/classes.html
+1 −1 documentation/test_python/inspect_string/modules.html
+1 −1 documentation/test_python/link_formatting/s.classes.html
+1 −1 documentation/test_python/link_formatting/s.modules.html
+1 −1 documentation/test_python/link_formatting/s.pages.html
+1 −1 documentation/test_python/page/pages.html
+1 −3 documentation/test_python/page_plugins/plots.html
+5 −4 package/ci/travis.yml
+12 −3 plugins/m/images.py
+21 −3 plugins/m/plots.py
+4 −12 plugins/m/test/plots/page-22.html
+4 −12 plugins/m/test/plots/page-30.html
+4 −12 plugins/m/test/plots/page-py35.html
+4 −12 plugins/m/test/plots/page.html
2 changes: 1 addition & 1 deletion extern/toml-test
1 change: 1 addition & 0 deletions include/toml++/toml.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ TOML_POP_WARNINGS // TOML_DISABLE_SPAM_WARNINGS
#undef TOML_LANG_HIGHER_THAN
#undef TOML_LANG_UNRELEASED
#undef TOML_LAUNDER
#undef TOML_LIFETIME_HOOKS
#undef TOML_LIKELY
#undef TOML_MAKE_BITOPS
#undef TOML_MAKE_VERSION
Expand Down
13 changes: 12 additions & 1 deletion include/toml++/toml_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ TOML_NAMESPACE_START
elements.emplace_back(impl::make_node(std::forward<T>(val)));
}

#if TOML_LIFETIME_HOOKS
void lh_ctor() noexcept;
void lh_dtor() noexcept;
#endif

public:

using value_type = node;
Expand Down Expand Up @@ -346,6 +351,9 @@ TOML_NAMESPACE_START
/// \brief Move-assignment operator.
array& operator= (array&& rhs) noexcept;

/// \brief Destructor.
~array() noexcept override;

/// \brief Constructs an array with one or more initial elements.
///
/// \detail \cpp
Expand Down Expand Up @@ -395,8 +403,11 @@ TOML_NAMESPACE_START
...
);
}
}

#if TOML_LIFETIME_HOOKS
lh_ctor();
#endif
}

[[nodiscard]] node_type type() const noexcept override;
[[nodiscard]] bool is_table() const noexcept override;
Expand Down
41 changes: 39 additions & 2 deletions include/toml++/toml_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,29 @@

TOML_NAMESPACE_START
{
#if TOML_LIFETIME_HOOKS

TOML_EXTERNAL_LINKAGE
void array::lh_ctor() noexcept
{
TOML_ARRAY_CREATED;
}

TOML_EXTERNAL_LINKAGE
array::array() noexcept = default;
void array::lh_dtor() noexcept
{
TOML_ARRAY_DESTROYED;
}

#endif

TOML_EXTERNAL_LINKAGE
array::array() noexcept
{
#if TOML_LIFETIME_HOOKS
lh_ctor();
#endif
}

TOML_EXTERNAL_LINKAGE
array::array(const array& other) noexcept
Expand All @@ -25,13 +46,21 @@ TOML_NAMESPACE_START
elements.reserve(other.elements.size());
for (const auto& elem : other)
elements.emplace_back(impl::make_node(elem));

#if TOML_LIFETIME_HOOKS
lh_ctor();
#endif
}

TOML_EXTERNAL_LINKAGE
array::array(array&& other) noexcept
: node{ std::move(other) },
elements{ std::move(other.elements) }
{}
{
#if TOML_LIFETIME_HOOKS
lh_ctor();
#endif
}

TOML_EXTERNAL_LINKAGE
array& array::operator= (const array& rhs) noexcept
Expand All @@ -58,6 +87,14 @@ TOML_NAMESPACE_START
return *this;
}

TOML_EXTERNAL_LINKAGE
array::~array() noexcept
{
#if TOML_LIFETIME_HOOKS
lh_dtor();
#endif
}

TOML_EXTERNAL_LINKAGE
void array::preinsertion_resize(size_t idx, size_t count) noexcept
{
Expand Down
Loading

0 comments on commit fe0ac89

Please sign in to comment.