2283 Commits

Author SHA1 Message Date
Milo Yip
91df56313b
Merge pull request #1335 from IceTrailer/master
Fixed parentheses in reader.h which were required to prevent the using of max macro
2018-08-01 11:55:44 +08:00
IceTrailer
cd28248611 Fixed parentheses in reader.h which were required to prevent the using of max macro 2018-07-31 22:23:53 +02:00
Veselin Georgiev
748a652f04 Fix SIGBUS due to unaligned access
Update RAPIDJSON_ALIGN() to always align on an 8-byte boundary
unless otherwise overridden.

On some platforms (such as ARM), 64-bit items (such as doubles and
64-bit integers) must be aligned to an 8 byte address, even though the
architecture is only 32-bits. On these platforms, MemoryPoolAllocator
must match the malloc() behavior and return a 8 byte aligned allocation.
This eliminates any alignment issues that may occur at the expense of
additional memory overhead.

Failure to do so caused a SIGBUS signal when calling
GenericValue::SetNull(). The size of the data_ member of the
GenericValue class is 16 bytes in 32-bit mode and its constructor
requires an 8-byte aligned access.

While parsing a JSON formatted string using Document::ParseStream(), a
stack object containing GenericValue items was constructed. Since the
stack was 8-byte aligned, the constructor calls would succeed. When the
lifetime of the object ends, SetObjectRaw() is invoked. This triggered
an allocation with 4-byte alignment to which the previously 8-byte
aligned GenericValue array was copied. After this, any call to a
GenericValue API that triggered the constructor and thus the placement
new operation on the Data type member would trigger a SIGBUS.

Signed-off-by: Veselin Georgiev <veselin.georgiev@garmin.com>
Signed-off-by: Joshua Watt <Joshua.Watt@garmin.com>
2018-07-31 09:02:26 -05:00
Philipp A Hartmann
f54f6b5aa9 Add RAPIDJSON_NOEXCEPT_ASSERT
This is an alternative implementation to #1284 to handle
asserts in noexcept contexts.

Closes #1280.
2018-07-18 12:02:24 +02:00
Minmin Gong
ff76343336 Update the code to adapt the new gtest. 2018-07-16 20:36:20 -07:00
Milo Yip
2bbd33b332
Merge pull request #1323 from pah/fix-memaccess
Fix warnings/errors on GCC 7/8 (-Wclass-memaccess, -Wsign-conversion, -Wformat-overflow)
2018-07-16 12:22:46 +08:00
Philipp A Hartmann
152511689b Suppress -Wformat-overflow warning/error
GCC 7 and later warn about overflow/truncation when using
sprintf and related functions with fixed-size buffers.

Suppress the warning in schematest.cpp.
2018-07-15 16:02:03 +02:00
Philipp A Hartmann
a26267d16d Fix -Wsign-conversion warnings/errors
GCC 8 (incorrectly) warns about sign conversions in (constant)
array size expressions:

error: conversion to 'long unsigned int' from 'int' may
change the sign of the result [-Werror=sign-conversion]
     char schemaBuffer_[128 * 1024];

Make these expressions unsigned by adding a 'u' suffix to
the first operands.
2018-07-15 16:01:02 +02:00
Philipp A Hartmann
fa5963a2f5 Fix -Wclass-memaccess warnings/errors
Recent GCC versions warn about using memcpy/memmove to
write to a class pointer (-Wclass-memaccess).

Avoid the warnings by casting to void* first.

Closes #1086.
Closes #1205.
Closes #1246.
2018-07-15 14:20:38 +02:00
Milo Yip
4b4583bdbe
Merge pull request #1320 from AnomalRoil/master
Removing always true if condition
2018-07-12 23:31:19 +08:00
Yolan Romailler
93331cb0cd Removing always true if condition 2018-07-12 15:13:19 +02:00
Christopher Warrington
960b9cfd19 Guard against min/max being macros in reader.h
Sometimes, particularly when Microsoft's windows.h is included, min/max
are defined as macros, interfering with use of
std::numeric_limits::min() and the like.

To guard against this, the function name is wrapped in an extra set of
parenthesis, which inhibits function-style macro expansion.

This is a similar commit to 6e38649ec6, but fixes uses of
std::numeric_limits added after that commit, like those introduced in
2ea43433e2.
2018-07-10 11:08:41 -07:00
Milo Yip
129d19ba7f
Merge pull request #1312 from erikfroseth/issue-1308
Detect C++11 features for Developer Studio
2018-07-03 20:28:24 +08:00
Erik Froseth
3e255af03a Detect C++11 features for Developer Studio
This patch enables various C++11 features if the code is compiled with
Developer Studio compiler version 5.14 or higher.
2018-07-03 13:02:45 +02:00
Milo Yip
b81438ea96
Merge pull request #1307 from moretromain/preprocessor_cleanup
Rename a few internal preprocessor macros to avoid naming conflicts
2018-07-03 10:34:32 +08:00
Tim Miller
fdd2db930f Updated google test to latest commit 2018-07-02 08:30:17 -04:00
Romain Moret
4595cc488e Rename a few internal preprocessor macros to avoid potential naming conflicts 2018-07-02 13:24:18 +02:00
Milo Yip
7e68aa0a21
Merge pull request #1252 from StilesCrisis/issue-1251-test
Unit Test: Parsing "128.74836467836484838364836483643636483648e-336" causes a crash
2018-06-19 12:43:54 +08:00
Milo Yip
c511ce303f
Merge pull request #1250 from StilesCrisis/issue-1249-test
Unit Test: Parsing "0e100" in full precision mode causes UB
2018-06-18 23:54:53 +08:00
Milo Yip
6cc3910a10
Merge pull request #1290 from abolz/fix-strtod
Fix strtod
2018-06-17 23:20:45 +08:00
abolz
7101911d9b Run all the new tests in full-precision mode only
until I know what the normal-precision algorithm really does...
2018-06-16 15:23:44 +02:00
abolz
319944a11a Disable failing test for now 2018-06-16 14:55:07 +02:00
abolz
a757a2aeb8 Add more tests
Some more need to be fixed.
2018-06-16 14:31:48 +02:00
abolz
179277817d Add a test for BigInteger::operator<< 2018-06-16 13:48:33 +02:00
abolz
a0f9c5fc46 [Debug - clean up] 2018-06-16 12:32:17 +02:00
abolz
879ae853fe Fix offset computation in BigInteger::operator<< 2018-06-16 09:41:04 +02:00
abolz
8b98f4a782 Workaround incorrect rounding in MSVC 2018-06-16 09:40:40 +02:00
abolz
a2813b6739 Limit exponents 2018-06-15 17:10:36 +02:00
abolz
6cd5cd7b94 [Debug - Initialize variable] 2018-06-15 16:01:52 +02:00
abolz
292f787c04 [Debug] 2018-06-15 15:10:50 +02:00
abolz
695c9cb976 Use C macros with the correct header instead of std::numeric_limits and static_cast
=D
2018-06-15 14:06:14 +02:00
abolz
1d636de81e Fix another signed/unsigned warning 2018-06-15 13:53:48 +02:00
abolz
a2a7d97b3b Use std::numeric_limits instead of macros 2018-06-15 13:50:19 +02:00
abolz
fc85fbeef0 Fix implicit signed/unsigned conversion and a small glitch in the error computation - part 2 2018-06-15 13:44:43 +02:00
abolz
16c97cd7c5 Fix implicit signed/unsigned conversion and a small glitch in the error computation 2018-06-15 13:44:15 +02:00
abolz
2ea43433e2 Fix bogus gcc warning 2018-06-15 13:41:44 +02:00
abolz
a78c8e3a4f Add more tests (which need to be fixed) 2018-06-15 12:59:39 +02:00
abolz
cb009f3050 Return infinity if binary exponent is too large 2018-06-15 12:59:05 +02:00
abolz
7acbb87c2b Some more tests 2018-06-15 11:39:45 +02:00
abolz
4e9b4f6d6a Return 0 if binary exponent is too small 2018-06-15 11:32:32 +02:00
abolz
f5e5d47fac Properly test for overflow
Do not use an approximation to do this. Instead check if the result is Inf.
2018-06-15 11:29:48 +02:00
abolz
d83d2ba260 Trim all zeros from input
If the buffer only contains zeros, return 0.
2018-06-15 10:46:45 +02:00
abolz
c59ecc857d Replace unsigned with signed integer arithmetic in strtod 2018-06-15 10:44:10 +02:00
abolz
29b6c9b7dc Add assertions to check preconditions of functions and unsigned integer arithmetic 2018-06-15 10:35:31 +02:00
abolz
80dba56aca Add tests for issues with string-to-double conversions (#849, #1249, #1251, #1253, #1256, #1259) 2018-06-15 10:15:45 +02:00
Milo Yip
01c71740cd
Merge pull request #1287 from Nekto89/msvc_config
MSVC: Autodetect RAPIDJSON_HAS_CXX11_NOEXCEPT, RAPIDJSON_HAS_CXX11_TYPETRAITS
2018-06-14 11:04:15 +08:00
Marian Klymov
2b0843037e Autodetect RAPIDJSON_HAS_CXX11_NOEXCEPT and RAPIDJSON_HAS_CXX11_TYPETRAITS for Visual Studio 2018-06-13 20:43:16 +03:00
Benjamin Lee
5b0610a74f Handle non-throwing exception specifications that can still throw #1280 2018-06-06 23:34:51 -07:00
Milo Yip
c0daf75475
Merge pull request #1279 from bogaotory/master
Avoid `MissingProperty` Error from `SchemaValidator` when a none-zero length value is given as `default` for the property
2018-06-02 15:20:05 +08:00
bogaotory
6f7dcb30d9 again, in relation to solving issue #784, use SizeType-typed variable to indicate a none-zero length string has been given in the schema as default value for the json property; added an unittest Object_Required_PassWithDefault 2018-06-01 21:16:26 +01:00