Skip to content

Commit

Permalink
fixed #187
Browse files Browse the repository at this point in the history
also:
- fixed #188
- fixed #189
- updated conformance tests
- version bump
  • Loading branch information
marzer committed Jan 29, 2023
1 parent d00464a commit 8f31ec8
Show file tree
Hide file tree
Showing 12 changed files with 7,551 additions and 4,035 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ template:
-->

## Unreleased
## v3.3.0

[Released](https://github.com/marzer/tomlplusplus/releases/tag/v3.3.0) 2023-01-29

#### Fixes:

- fixed null pointer dereference in parser when exceptions are disabled (#169) (@ncaklovic)
- fixed spurious warnings in MSVC 19.34
- fixed `toml::parse_file()` on windows for non-ASCII paths
- fixed a spurious table redefinition error (#187) (@jorisvr)
- fixed UB edge-case in integer parsing (#188) (@jorisvr)
- fixed some build issues with Apple-flavoured Clang (#189) (@eddelbuettel)

#### Additions:

Expand Down
36 changes: 29 additions & 7 deletions include/toml++/impl/parser.inl
Original file line number Diff line number Diff line change
Expand Up @@ -2262,14 +2262,21 @@ TOML_IMPL_NAMESPACE_START
}

// range check
if TOML_UNLIKELY(result > static_cast<uint64_t>((std::numeric_limits<int64_t>::max)()) + (sign < 0 ? 1ull : 0ull))
static constexpr auto i64_max = static_cast<uint64_t>((std::numeric_limits<int64_t>::max)());
if TOML_UNLIKELY(result > i64_max + (sign < 0 ? 1u : 0u))
set_error_and_return_default("'"sv,
traits::full_prefix,
std::string_view{ digits, length },
"' is not representable in 64 bits"sv);

if constexpr (traits::is_signed)
{
// avoid signed multiply UB when parsing INT64_MIN
if TOML_UNLIKELY(sign < 0 && result == i64_max + 1u)
return (std::numeric_limits<int64_t>::min)();

return static_cast<int64_t>(result) * sign;
}
else
return static_cast<int64_t>(result);
}
Expand Down Expand Up @@ -3252,13 +3259,28 @@ TOML_IMPL_NAMESPACE_START

else if (auto tbl = matching_node.as_table(); !is_arr && tbl && !implicit_tables.empty())
{
if (auto found = impl::find(implicit_tables.begin(), implicit_tables.end(), tbl);
found && (tbl->empty() || tbl->is_homogeneous<table>()))
if (auto found = impl::find(implicit_tables.begin(), implicit_tables.end(), tbl); found)
{
implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data()));
tbl->source_.begin = header_begin_pos;
tbl->source_.end = header_end_pos;
return tbl;
bool ok = true;
if (!tbl->empty())
{
for (auto& [_, child] : *tbl)
{
if (!child.is_table() && !child.is_array_of_tables())
{
ok = false;
break;
}
}
}

if (ok)
{
implicit_tables.erase(implicit_tables.cbegin() + (found - implicit_tables.data()));
tbl->source_.begin = header_begin_pos;
tbl->source_.end = header_end_pos;
return tbl;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/toml++/impl/preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
__pragma(warning(push)) \
static_assert(true)

#if TOML_HAS_INCLUDE(<CodeAnalysis / Warnings.h>)
#if TOML_HAS_INCLUDE(<CodeAnalysis/Warnings.h>)
#pragma warning(push, 0)
#include <CodeAnalysis/Warnings.h>
#pragma warning(pop)
Expand Down
2 changes: 1 addition & 1 deletion include/toml++/impl/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#define TOML_LIB_MAJOR 3
#define TOML_LIB_MINOR 2
#define TOML_LIB_MINOR 3
#define TOML_LIB_PATCH 0

#define TOML_LANG_MAJOR 1
Expand Down
11 changes: 4 additions & 7 deletions include/toml++/toml.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

#define INCLUDE_TOMLPLUSPLUS_H // old guard name used pre-v3

//# Note: these would be included transitively as with any normal C++ project but
//# they're listed explicitly here because this file is used as the source for generate_single_header.py.

#include "impl/preprocessor.h"

TOML_PUSH_WARNINGS;
Expand All @@ -24,12 +21,12 @@ TOML_DISABLE_SUGGEST_ATTR_WARNINGS;
#pragma warning(disable : 4251) // dll exports for std lib types
#endif
#elif TOML_CLANG
#pragma clang diagnostic ignored "-Wheader-hygiene"
TOML_PRAGMA_CLANG(diagnostic ignored "-Wheader-hygiene")
#if TOML_CLANG >= 12
#pragma clang diagnostic ignored "-Wc++20-extensions"
TOML_PRAGMA_CLANG(diagnostic ignored "-Wc++20-extensions")
#endif
#if TOML_CLANG == 13 && !defined(__APPLE__)
#pragma clang diagnostic ignored "-Wreserved-identifier"
#if TOML_CLANG == 13
TOML_PRAGMA_CLANG(diagnostic ignored "-Wreserved-identifier")
#endif
#endif

Expand Down
Loading

0 comments on commit 8f31ec8

Please sign in to comment.