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
{{ message }}
Repository navigation
Preserve whitespace-prefixed multiline values when quotes are enabled - #102
With SetQuotes(true) and SetMultiLine(true), a value beginning with whitespace is quoted before the writer checks for embedded newlines. For example, " first\nsecond" is saved as:
[section]key = " firstsecond"
Reloading returns only " first, including the opening quote, and drops the second line.
Move the leading-whitespace check in IsSingleLineQuotedValue after its newline scan, so multiline values use the existing multiline serializer. Single-line whitespace and quoted-string handling stay the same.
The regression test covers leading space, tab, and newline, whitespace-only content, trailing whitespace, and an end-tag collision.
Validation
Unmodified upstream fd6db69efc40a687bf4ef81486b54066e34992dd: reproducer and new regression fail; existing 284 tests pass
Patched: 285 tests pass with GCC 14.2, C++17, Debug, warnings as errors
make format-check passes with clang-format 18.1.8; git diff --check passes
Independent standalone review: 15,652 char/wchar boundary checks pass under ASan/UBSan, including quote modes, CR/CRLF normalization, and tag collisions
Full sanitizer suite passes all 285 tests with ASAN_OPTIONS=detect_leaks=0:alloc_dealloc_mismatch=0
Without that allocation-mismatch adjustment, both pristine and patched full sanitizer test binaries abort before test bodies: the existing allocation-failure hooks return malloc storage from nothrow operator new, while GoogleTest frees a temporary buffer with operator delete. The standalone checks do not need that adjustment. Leak detection was disabled because it cannot run under the sandbox's ptrace environment. Windows, macOS, and ARM were not tested locally.
Independently verified the functional bug on master (fd6db69) and the fix on this branch (fe0ba0d). No code changes from this review.
On the sanitizer / malloc note in the description: the diagnosis is correct, and it is pre-existing. It is not introduced by this PR.
tests/ts-regressions.cpp replaces only the nothrow operator new / operator new[] and returns __wrap_malloc() / __real_malloc() storage. It does not replace any operator delete / operator delete[], including the sized overloads.
The first abort is not GoogleTest calling new (std::nothrow) itself. testing::TestSuite::Run() calls std::stable_sort on its TestInfo* vector. libstdc++ std::get_temporary_buffer then does ::operator new(n, std::nothrow) (stl_tempbuf.h), which hits the test hook and gets malloc memory. The matching free is sized ::operator delete(p, n) from __return_temporary_buffer. ASan reports alloc-dealloc-mismatch (malloc vs operator delete) at the start of the first suite, before any test body runs.
Confirmed on both pristine master and this PR with GCC 13.3, ASan+UBSan. ASAN_OPTIONS=alloc_dealloc_mismatch=0 is a valid workaround for running the suite, not a fix. With detect_leaks=1:alloc_dealloc_mismatch=0, all 285 tests passed here, so leak detection is a separate environment limitation rather than something this hook inherently breaks.
A follow-up (not this PR) should pair those nothrow new replacements with matching delete/delete[] overloads that call free, including operator delete(void*, std::size_t). SimpleIni itself also uses new (std::nothrow) and delete[], so the same mismatch would fire in library paths if the suite ever got past the stable_sort abort.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With
SetQuotes(true)andSetMultiLine(true), a value beginning with whitespace is quoted before the writer checks for embedded newlines. For example," first\nsecond"is saved as:Reloading returns only
" first, including the opening quote, and drops the second line.Move the leading-whitespace check in
IsSingleLineQuotedValueafter its newline scan, so multiline values use the existing multiline serializer. Single-line whitespace and quoted-string handling stay the same.The regression test covers leading space, tab, and newline, whitespace-only content, trailing whitespace, and an end-tag collision.
Validation
fd6db69efc40a687bf4ef81486b54066e34992dd: reproducer and new regression fail; existing 284 tests passmake format-checkpasses with clang-format 18.1.8;git diff --checkpassesASAN_OPTIONS=detect_leaks=0:alloc_dealloc_mismatch=0Without that allocation-mismatch adjustment, both pristine and patched full sanitizer test binaries abort before test bodies: the existing allocation-failure hooks return
mallocstorage from nothrowoperator new, while GoogleTest frees a temporary buffer withoperator delete. The standalone checks do not need that adjustment. Leak detection was disabled because it cannot run under the sandbox's ptrace environment. Windows, macOS, and ARM were not tested locally.