This patch fixes the issue where parsing NaN or Inf values with
fractional or exponent parts would return incorrect results
(e.g., "NaN.2e2" would be parsed as 20).
Before this patch, the parser would continue to process the fractional
and exponent parts even after successfully parsing a valid NaN or Inf,
which could lead to parsing errors. This patch adds a check for such
cases to skips the parsing of the fractional and exponent parts after
completing the NaN and Inf parsing.
valgrind is not present on all architectures (eg riscv64) and might
not be installed even on supported architectures.
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
In the constructor for GenericRegexSearch, there was an issue with a
static_cast casting the result of the Malloc call. The issue was that
the stateSet_ member is of type uint32_t*, and there was an attempt to
assign an unsigned* to it. On some systems, uint32_t is not equivalent
to unsigned, thus yielding a compile error for assigning pointers of
different type.
Change-Id: I5b5036100305510b83cc4893b784a2dc9f3e4849
One of multipleOf test failed because most floating-point numbers end
up being slightly imprecise. And, the check of multipleOf with two
double numbers using the dividend (a) and the result of multiplying
the multiple after rounding down by the divisor (floor(|a|/|b|)*b) to
compare.
Change to using std::numeric_limits::epsilon to check the error of
the division result.
The identifier 'allocator' in the RapidJSON StdAllocator class declaration shadows the identifier 'allocator' in the
std::allocator class. To fix this, rename the 'allocator'
identifier in the StdAllocator class declaration to a different name.
In the BigNestedObject test case of valuetest.c, a dynamically
defined format is used that depends on the signedness of the
'SizeType' type. This allows the 'sprintf' function to use the correct
format for 'SizeType'.
Change-Id: I97222b699bda6c0ccfc9abbc5977c79e16605f2c
Remove useless comment block which owns a '\see' cross-reference, but
doesn't provide any data after it. This empty cross-reference triggers
a compiler warning.
Change-Id: I5c01d57579e5efedcb4bf17b80b06db313a61ab3
When using running both Undefined Behavior Sanitizer (UBSan) and
Hardware-Assisted Address Sanitizer (HWASan) on Fuchsia, ubsan
complained about a pointer overflow when computing the new token->name pointer.
This happens because the initial pointer diff takes the offset between
two allocations with different tags, so the arithmetic results in a very
large diff that gets added to the original token->name ptr which
overflows.
Any arithmetic between pointers to two allocations is unspecified
behavior, so hwasan+ubsan is catching a bug here. It looks like
rapidjson is just attempting to update the name pointers to strings
copied into the new nameBuffer_ via this arithmetic, but since these
strings and the tokens are in the same buffer, the offset between them
should be the same. For each token we can just get this offset and
adjust the new name pointers accordingly which avoids the bad arithmetic.
A change to the semantics of equality operator rewriting in C++20 (P2468R2: The Equality Operator You Are Looking For) means that operator== may not be rewritten with reversed operands if operator!= is also defined. Since operator!= can normally be synthesized from operator== regardless in this language standard, we can and should avoid defining those when the new language semantics are available.
This fixes the compilation of tests (and probably consuming code) in C++20 onwards for compilers that implement this new semantic, including recent nightly builds of clang-16.
Reference: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2468r2.html