2481 Commits

Author SHA1 Message Date
Mikhail Khachayants
24b5e7a8b2 Fix out of bounds read with kParseValidateEncodingFlag 2025-02-05 21:28:08 +08:00
Aikawa Yataro
b1c0c2843f CMakeLists: include path fix + compatibility. 2025-02-05 21:25:33 +08:00
Mikhail Khachayants
d621dc9e9c Fix parsing 0.184467440737095516159 with kParseFullPrecisionFlag 2024-12-18 19:30:59 +08:00
SilverPlate3
58c6938b73 Guard against max being macros in schema.h
Similar to:
Issue - https://github.com/Tencent/rapidjson/issues/1033
Solution - 6e38649ec6

Fix std::numeric_limits::max() compilation confusion on Windows
2024-12-10 17:21:10 +08:00
SilverPlate3
9b5cad1649 Cpp version depended if constexpr schema.h
Fix windows compile warning C4127
2024-12-10 17:19:59 +08:00
SilverPlate3
535636aeae Cpp depended if constexpr pointer.h
Fix windows compile warning C4127
2024-12-10 17:19:59 +08:00
Christian Fersch
ebd87cb468 Increase CMake minimum version to 3.5 (fixes #2159) 2024-12-02 19:40:10 +08:00
RedContritio
858451e5b7 Fix endif condition to match NOT MSVC and VALGRIND_FOUND. 2024-10-07 20:17:31 +08:00
Dmitriy Tretyakov
815e6e7e7e add test for sso optimized string 2024-09-24 17:14:47 +08:00
Dmitriy Tretyakov
805d7ed5df Fix issue 2307
In case sso use memmove to avoid memory overlapping issues
2024-09-24 17:14:47 +08:00
Eyizoha
7c73dd7de7 Fix bug when parsing NaN, Inf with fraction or exponent parts (fixes #2299)
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.
2024-08-16 20:24:45 +08:00
Sergey Fedorov
ab1842a2da rapidjson.h: add forgotten ppc64 case 2024-04-09 17:58:25 +08:00
Brian Rogers
5ec44fb920 Add RAPIDJSON_BUILD_CXX20 option
The travis/appveyor files are updated to reference this option, but it is
not yet enabled in any of the build configurations.
2024-03-08 10:18:11 +08:00
Gilles Vollant
676d99db96 fix Visual Studio 2022 (using /std:c++20) warning warning C5232: in C++20 this comparison calls ... recursively 2024-03-08 10:17:06 +08:00
Richard W.M. Jones
68afb49287 tests: Only run valgrind tests if valgrind was found
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>
2024-03-07 14:41:57 +08:00
Dylan Burr
3f73edae00 Fix static_cast in regex.h
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
2024-02-09 21:47:20 +08:00
Esther Wang
5a74efa8c7 Fix comparision of two doubles
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.
2024-02-09 19:29:03 +08:00
Bryant Ferguson
060a09a1c5 Fix schema regex preprocessor include logic 2024-02-09 19:28:14 +08:00
Esther Wang
6089180ecb Use correct format for printf
Change the printf format from '%d' to '%u', matching the type of the
arguments.
2023-12-06 19:08:30 +08:00
Aikawa Yataro
f9d53419e9 Add Hasher tests for objects where key eq value 2023-09-28 16:06:09 +01:00
Aikawa Yataro
6f79698b35 Fix swapped high and low offset basis values 2023-09-28 16:06:09 +01:00
Aikawa Yataro
eee82cb078 Fix object hashing in schema 2023-09-28 16:06:09 +01:00
Jeroen Doggen
b4a6da3e63 unit tests for 'Stringify NaN, Inf as null' 2023-09-21 18:42:43 +01:00
Jeroen Doggen
e7b6e5a208 Fix: 'Stringify NaN, Inf as null'
The code path where 'null' is written was never reached when 'writeFlags == kWriteNanAndInfNullFlag'
2023-09-21 18:42:43 +01:00
Albert Hung (Embedded)
476ffa2fd2 Rename to fix allocator shadowing
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.
2023-08-21 11:02:43 +08:00
Albert Hung
5e17dbed34 Eliminate old style cast warning
Use static_cast to replace old style cast.

Change-Id: I30e659c8f2aadc02750555b0f041bfd2e1c8004a
2023-08-17 16:55:04 +08:00
Albert Hung
956063dbc1 Fixing printf format warning
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
2023-08-15 17:03:49 +08:00
Milo Yip
30f54566ad
Merge pull request #1901 from JackBoosY/master
Use modern cmake function export to generate target
2023-08-14 18:08:52 +08:00
Albert Hung
516d047394 Remove empty cross-reference in comment
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
2023-08-14 18:08:33 +08:00
miloyip
52dd947090 Merge branch 'master' into pr/1901 2023-08-14 11:00:53 +01:00
Jihadist
a95e013b97 Stringify NaN, Inf as null if needs 2023-07-17 11:02:35 +08:00
Leonard Chan
973dc9c06d Avoid ptrdiff between pointers to different allocations
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.
2023-05-17 16:16:27 +08:00
Albert Hung
2a1f586ba6 Check for __GNUC__ definition
Wrap code checking against __GNUC__ to ensure it is defined. This can cause errors with compilers which do not define this preprocessor value.
2023-05-10 12:41:04 +08:00
Albert Hung
0e88d5e404 Eliminate missing prototypes warning 2023-05-09 21:28:14 +08:00
Flaviu_
949c771b03 Resolve conflict with Windows header about max macro 2023-04-07 18:45:27 +08:00
Sergey Fedorov
083f359f5c CMakeLists: fix optflags for ppc 2023-03-06 14:36:52 +08:00
supperpiccle
012be85287 Use passed in allocator. 2023-01-12 14:24:04 +08:00
Steve Hanson
1ce516e50b Suppress uritest 2023-01-05 20:34:07 +08:00
Steve Hanson
778dc8b03e fix #1 2023-01-05 20:34:07 +08:00
Tana0910
76281ff388 fix a typo in error.h: literial -> literal 2023-01-04 17:45:39 +08:00
Kent Ross
a98e99992b do not define operator!= in C++20
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
2022-12-19 05:30:49 +08:00
Steve Hanson
b08672d469 review comment updates 2022-12-19 05:30:00 +08:00
Steve Hanson
55eca66f39 code & tests for openapi 2.0 & 3.0 suppprt 2022-12-19 05:30:00 +08:00
Steve Hanson
80b6d1c834 small corrections for schema.h 2022-12-01 00:42:44 +08:00
Steve Hanson
97fd830175 attempt to fix SEH 2022-12-01 00:42:44 +08:00
Steve Hanson
7cad78e236 tidy up after merge from master 2022-12-01 00:42:44 +08:00
Steve Hanson
794248ee62 fix build break 2022-12-01 00:42:44 +08:00
Steve Hanson
2d87923e91 remove unnecessary templating from schema tests 2022-12-01 00:42:44 +08:00
Steve Hanson
aa1f22251f correct address.json so tests pass 2022-12-01 00:42:44 +08:00
Steve Hanson
ecb8d9e3a0 add dump of unexpected schema errors in schematest.cpp 2022-12-01 00:42:44 +08:00