2301 Commits

Author SHA1 Message Date
Konstantin Käfer
16872af889 Avoid pointer arithmetic on null pointer to remove undefined behavior
The existing checks triggered undefined behavior when the stack was empty (null pointer). This change avoid this:
* If `stackTop_` and `stackEnd_` are null, it results in a `ptrdiff_t` of `0`
* If `stackTop_` and `stackEnd_` are valid pointers, they produce a `ptrdiff_t` with the remaining size on the stack
2018-10-05 09:26:20 +02:00
Milo Yip
663f076c7b
Merge pull request #1362 from jiapengwen/master
fix tutorial error
2018-09-19 12:58:56 +08:00
Milo Yip
2a5e733b6f
Merge pull request #1364 from jcourtat/fixfaq
faq: fix document insertion example
2018-09-19 12:58:14 +08:00
Julien Courtat
68349ed914 faq: fix document insertion example
GenericDocument contructor requires a pointer to an Allocator, but GetAllocator() only
returns a reference.

Signed-off-by: Julien Courtat <julien.courtat@aqsacom.com>
2018-09-18 14:51:12 +02:00
jiapeng.wen
1cfa861d4c fix tutorial error 2018-09-18 10:51:16 +08:00
Milo Yip
c0ca05f6dd
Merge pull request #1329 from pah/fix-noexcept
Add RAPIDJSON_NOEXCEPT_ASSERT
2018-09-11 10:13:09 +08:00
Milo Yip
c2aa79dc88
Merge pull request #1356 from gongminmin/AppVeyor2017
Update appveyor rule to support VS2017.
2018-09-10 16:59:39 +08:00
Milo Yip
783b819e67
Update rapidjson.h 2018-09-10 13:11:17 +08:00
Minmin Gong
a6be583efa Update appveyor rule to support VS2017. 2018-09-09 20:58:02 -07:00
Milo Yip
8a96a95de2
Merge branch 'master' into fix-noexcept 2018-09-10 11:27:45 +08:00
Milo Yip
f5f6052c56
Merge pull request #1327 from gongminmin/FixCompileInVS
Fix the compiling problems in VS
2018-09-10 11:23:26 +08:00
Milo Yip
08b1a8a41e
Merge pull request #1302 from chwarr/min-max-guard
Guard against min/max being macros in reader.h
2018-09-10 11:22:28 +08:00
Milo Yip
81af404b7f
Merge pull request #1284 from mobileben/noexcept-assert
Handle non-throwing exception specifications that can still throw #1280
2018-09-10 11:21:34 +08:00
Milo Yip
73063f5002
Merge pull request #1340 from lelit/issue1336
Wrap all WriteXxx() calls within EndValue()
2018-08-05 19:01:46 +08:00
Lele Gaifax
c9eabf9e13 Extend the test on issue #1336 to cover all basic types 2018-08-05 09:44:15 +02:00
Lele Gaifax
3fc9299b84 Add simple test for issue #1336 2018-08-03 12:34:03 +02:00
Lele Gaifax
11defb7aa4 Wrap all WriteXxx() calls within EndValue(), to ensure a flush after root-level scalar value
This attempts to fix issue #1336.
2018-08-03 12:17:29 +02:00
Milo Yip
6a905f9311
Merge pull request #1331 from JPEWdev/mem-alignment-fix
Fix SIGBUS due to unaligned access
2018-08-01 11:56:25 +08:00
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