1835 Commits

Author SHA1 Message Date
Eli Fidler
21acc56d57 range check in IsLosslessFloat to avoid undefined double->float cast
UBSAN gave in Value.IsLosslessFloat:
include/rapidjson/document.h:981:38: runtime error: value 3.40282e+38 is outside the range of representable values of type 'float'
2016-06-14 07:01:41 -07:00
Eli Fidler
c52cec7e51 fix undefined double to uint64_t cast
note that std::numeric_limits<uint64_t>::max() and
std::numeric_limits<int64_t>::max() aren't exactly representable in a
double, so we need to be strictly less to be definitely lossless

UBSAN gave during Value.IsLosslessDouble test:
include/rapidjson/document.h:955:42: runtime error: value 1.84467e+19 is outside the range of representable values of type 'unsigned long'
2016-06-14 07:01:41 -07:00
Eli Fidler
05f0592b34 avoid shift out-of-range error
UBSAN gave in Regex.Unicode test:
include/rapidjson/encodings.h:157:28: runtime error: shift exponent 32 is too large for 32-bit type 'int'
2016-06-14 07:01:41 -07:00
Eli Fidler
9dcf51c3a1 avoid shift out-of-range error
UBSAN gave during Reader.ParseNumber_FullPrecisionDouble test:
include/rapidjson/internal/strtod.h:149:11: runtime error: shift exponent 46 is too large for 32-bit type 'int'
2016-06-14 07:01:41 -07:00
Eli Fidler
df9b45a656 avoid division by zero, which is undefined behavior
UBSAN gave:
runtime error: division by zero
2016-06-14 07:01:41 -07:00
Eli Fidler
760ea4316c avoid signed-integer underflow, which is undefined behavior
maybe these tests should just be deleted?

UBSAN gave:
runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long'
runtime error: signed integer overflow: -9223372036854775808 - 2 cannot be represented in type 'long'
2016-06-14 07:01:41 -07:00
Eli Fidler
be1eedf808 avoid signed-integer overflow, which is undefined behavior
UBSAN gave for test/unittest/itoatest.cpp:87:
runtime error: signed integer overflow: 4611686018427387904 * 2 cannot be represented in type 'long'
2016-06-14 07:01:41 -07:00
Eli Fidler
61637d3382 avoid passing a null pointer to memcpy
UBSAN on Clang/Linux gave:
runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:43:45: note: nonnull attribute specified here
2016-06-13 07:24:26 -07:00
Eli Fidler
8074b722f0 avoid reference to null pointer and member access within null pointer
UBSAN gave issues with the typeless Schema:
runtime error: reference binding to null pointer of type 'rapidjson::GenericSchemaDocument<rapidjson::GenericValue<rapidjson::UTF16<wchar_t>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >, rapidjson::CrtAllocator>'
and
runtime error: member access within null pointer of type 'AllocatorType' (aka 'rapidjson::CrtAllocator')
2016-06-13 07:24:26 -07:00
Eli Fidler
fe550f3866 avoid array index out-of-bounds
UBSAN gave "runtime error: index 13 out of bounds for type 'const uint32_t [10]'"
2016-06-13 07:24:26 -07:00
Eli Fidler
5c77c9248c with recent clang, this triggers -Wunevaluated-expression
specifically, "expression with side effects has no effect in an unevaluated context"
2016-06-13 07:24:26 -07:00
Eli Fidler
035271091f with recent clang, when expected is false, this code triggers -Wunreachable-code
clang advises: "note: silence by adding parentheses to mark code as explicitly dead"
2016-06-13 07:24:26 -07:00
Eli Fidler
13e3aa9b00 we do need to avoid the double-promotion warning on clang, since we're compiling with -Werror 2016-06-13 07:24:26 -07:00
Eli Fidler
89f6b8a380 Clang doesn't like the C-style casts in nmmintrin.h 2016-06-13 07:24:26 -07:00
Eli Fidler
56bb9992b0 support building with ASAN and UBSAN on Clang and GCC 2016-06-13 07:24:26 -07:00
Milo Yip
2e66339137 Disable parsebyparts example for clang 2016-06-13 09:54:02 +08:00
Milo Yip
fee5190def Fix a clang warning 2016-06-13 09:34:47 +08:00
Milo Yip
024fc49586 Merge pull request #654 from efidler/travis-clang
switch Clang from broken Ubuntu PPA to upstream binary release
2016-06-13 09:21:02 +08:00
Eli Fidler
d1697f7437 use included clang on travis
This should fix the Travis clang builds, since the upstream LLVM apt
repo is down.
2016-06-10 15:21:29 -04:00
Milo Yip
6f5e83db04 Merge pull request #639 from milkandsour/master
npm docs
2016-06-10 11:31:00 +08:00
Milo Yip
ba54d02871 Merge pull request #656 from miloyip/pr/651
Fix cmake build with new gtest reference
2016-06-09 21:26:37 -05:00
Milo Yip
ce3ca58fee Change googletest search path for cmake 2016-06-10 10:15:45 +08:00
Zhang Ye
47d7320096 Update reference to gtest thirdparty module. 2016-06-08 09:36:03 +08:00
Milo Yip
e6895ec115 Merge pull request #641 from m7thon/allow_nan_and_inf
Allow options for writing and parsing NaN/Infinity
2016-05-22 20:55:04 -05:00
Michael Thon
135da7ab34 Allow options for writing and parsing NaN/Infinity
This adds kWriteNanAndInfFlag to Writer to allow writing of nan,
inf and -inf doubles as "NaN", "Infinity" and "-Infinity",
respectively, and kParseNanAndInfFlag to Reader to allow parsing
of "NaN", "Inf", "Infinity", "-Inf" and "-Infinity". This is part
of issue #36, adding optional support for relaxed JSON syntax.
2016-05-20 23:54:55 +02:00
Andrea Colaci
f9810e548b 1.0.4 2016-05-17 13:33:43 +01:00
Andrea Colaci
7708961484 npm docs 2016-05-17 13:33:26 +01:00
Milo Yip
2a3fbdaf5c Merge pull request #631 from milkandsour/master
npm compliant package.json
2016-05-11 01:34:39 -05:00
Milo Yip
30111dbf4d Merge pull request #635 from gggin/master
fix some document problem
2016-05-10 22:37:17 -05:00
liujiayang
e154f8e959 add space for template 2016-05-11 11:01:47 +08:00
liujiayang
7b32bbaae7 fix document problem 2016-05-11 10:59:56 +08:00
Milo Yip
4b8cc94a25 Merge pull request #634 from Eswcvlad/master
Added missing include guards in istreamwrapper.h and ostreamwrapper.h
2016-05-10 18:45:43 -05:00
Vlad Lipskiy
819ba73b17 Added missing include guards in istreamwrapper.h and ostreamwrapper.h 2016-05-10 18:09:01 +03:00
Milo Yip
7cc76a9d46 Fix #630 2016-05-10 13:20:03 +08:00
Andrea Colaci
f8df637783 include folder added 2016-05-09 16:45:18 +01:00
Andrea Colaci
0febc29f1a refs 2016-05-09 16:33:35 +01:00
Andrea Colaci
af327524ed package update 2016-05-09 16:31:37 +01:00
Andrea Colaci
cf8f08f9d0 include dirs 2016-05-09 16:29:15 +01:00
Andrea Colaci
5bff05963c package json 2016-05-09 16:19:10 +01:00
Milo Yip
c02d52ad56 Fix documentation mistake in #620 2016-04-29 17:45:09 +08:00
Milo Yip
a636c79487 Merge pull request #618 from danvk/patch-1
Fix filterkeydom link
2016-04-27 11:53:44 +08:00
Dan Vanderkam
6b6b121ff0 Fix filterkeydom link 2016-04-26 19:24:52 -04:00
Milo Yip
1d9cb20a41 Merge pull request #617 from brucestephens/master
Define RAPIDJSON_HAS_CXX11_RVALUE_REFS directly in clang
2016-04-25 23:14:47 +08:00
Bruce Stephens
ee4207b3f0 Define RAPIDJSON_HAS_CXX11_RVALUE_REFS directly in clang
This makes no difference except that it avoids "warning: macro expansion
producing 'defined' has undefined behavior" messages.
2016-04-25 13:03:39 +01:00
Milo Yip
fdf665d637 Merge pull request #615 from miloyip/example
Add filterkey and filterkeydom examples
2016-04-23 08:26:03 -05:00
Milo Yip
00ed0a5f91 Fix gcc warning 2016-04-23 20:54:06 +08:00
Milo Yip
b010f388d1 Change FilterKeyHandler from struct to class
Also disable copy constructor/assignment operator
2016-04-23 20:11:05 +08:00
Milo Yip
05b2ed7532 Add filterkey and filterkeydom examples 2016-04-23 16:02:40 +08:00
Milo Yip
96ca84798f Merge branch 'master' into example 2016-04-23 16:02:02 +08:00
Milo Yip
e4ff9c0ee4 Merge pull request #614 from miloyip/zh-doc
Adding spaces in Chinese doc
2016-04-23 03:00:58 -05:00