Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert in unique_ptr::operator* #169

Closed
ncaklovic opened this issue Aug 31, 2022 · 1 comment
Closed

Assert in unique_ptr::operator* #169

ncaklovic opened this issue Aug 31, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ncaklovic
Copy link

Environment

TOML++ version 3.2.0

Compiler:
GCC 10

C++ standard mode:
C++ 17

Library configuration overrides:
TOML_ENABLE_FORMATTERS 0
TOML_EXCEPTIONS 0

Describe the bug

Assert in unique_ptr::operator*

Steps to reproduce (or a small repro code sample)

Use value in TOML whih does not parse, like

[a]
b = [c"]

Additional information

  • parser::parse_array() calls array::emplace_back() even if parse_value() fails
  • array::emplace_back() does insert_at_back() and return *elems_.back(); - which is dereferencing nullptr.
  • dereferencing nullptr is undefined behavior - MSVC lets it pass, but GCC (libstdcpp) has proper assert.

The simplest fix probably would be something like 4a4bf1e. I didn't do PR because I would expect that some of the tests running on GCC already found the problem.

@ncaklovic ncaklovic added the bug Something isn't working label Aug 31, 2022
@marzer marzer closed this as completed in 7876c96 Aug 31, 2022
@marzer
Copy link
Owner

marzer commented Aug 31, 2022

Ah, yup, looks like parse_array() was assuming that parse_value() throws on failure, not taking into account exceptionless mode - a silly oversight on my part. Have pushed a fix to master.

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants