1851 Commits

Author SHA1 Message Date
Milo Yip
5e8a382c19 Merge pull request #674 from sjasonsmith/master
Make GenericSchemaDocument constructor explicit
2016-07-02 21:00:47 +08:00
Jason Smith
899156172d Make GenericSchemaDocument constructor explicit
Prior to this change, a user could incorrectly pass a Document object to
SchemaValidator. This would implicitly construct a SchemaDocument, which
would then be destructed before the validator was used. This caused
unpredictable results including memory corruption and program crashes.
2016-07-01 06:59:07 -07:00
Milo Yip
727e2b958d Merge pull request #673 from sjasonsmith/master
Fix buffer overrun using PutN (closes #672)
2016-07-01 17:44:01 +08:00
Jason Smith
252e8122bf Fix buffer overrun using PutN (closes #672)
Fix inconsistent calling of template functions in PutN in stream.h. When
used with a GenericStringBuffer<<UTF8>, MemoryPoolAllocator>, PutN would call
PutReserve from stream.h, and PutUnsafe from stringbuffer.h. This
resulted in bytes being added to the buffer without allocating space.

This was not an issue when used with the default memory allocator,
because in this case the specialized PutN is used from stringbuffer.h.
2016-06-30 14:18:14 -07:00
Milo Yip
c79958a29b Fix #670 remote schema provider document 2016-06-29 09:48:38 +08:00
Milo Yip
f51d7c9d4b Merge pull request #669 from pah/fixes/666
readertest: Suppress "dangling-else" warning on GCC 7 and later
2016-06-28 09:58:22 +08:00
Philipp A. Hartmann
ad32940da8 readertest: Suppress "dangling-else" warning on GCC 7 and later
GCC 6.x doesn't yet support this warning flag, as reported by
@ragnar-ouchterlony.
2016-06-27 19:05:29 +02:00
Milo Yip
6da92274ae Merge pull request #667 from pah/fixes/666
Fix warnings on GCC 6 and later (closes #666)
2016-06-27 09:58:14 +08:00
Milo Yip
cf7324b466 Merge pull request #660 from andytimes/for-milo
document typo fix and .gitignore update
2016-06-27 09:35:42 +08:00
Philipp A. Hartmann
f6a07692f9 Fix warnings on GCC 6 and later (closes #666)
* document.h
  * suppress -Wterminate on GCC 6.x and later
  * simplify warning handling
* schema.h
  * drop RAPIDJSON_NOEXCEPT from GenericSchemaDocument constructor
    (calls RAPIDJSON_NEW anyway)
  * simplify warning handling
    (avoids RAPIDJSON_POP mismatch on Clang)
* encodingtest.cpp, istreamwrappertest.cpp
  * work around -Wdangling-else
* readertest.cpp
  * suppress -Wdangling-else
2016-06-23 21:42:16 +02:00
Andy Deng
dabbd2b028 gitignore: ignore Doxyfile.zh-cn
Doxyfile.zh-cn is a generated file that we need to ignore.
2016-06-15 11:56:20 +08:00
Andy Deng
2246ef3e6b doc/tutorial-zh-cn: Fix a typo in tutorial 2016-06-15 11:53:23 +08:00
Milo Yip
1c087b77cb Fix #650 SAX documentation bug 2016-06-15 09:46:30 +08:00
Milo Yip
b34f18525e Fix tutorial bug 2016-06-15 09:41:56 +08:00
Milo Yip
62ff0a9df9 Merge pull request #646 from efidler/ubsan
Fix undefined behaviour
2016-06-15 09:35:12 +08:00
Eli Fidler
8c4059766e test for no-double-promotion instead of just checking compiler version 2016-06-14 07:01:41 -07:00
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