857 Commits

Author SHA1 Message Date
Milo Yip
769185d68b Refactor regex
Remove mutable which causes reentrant issue
2016-09-16 12:13:02 +08:00
Milo Yip
3e2172bd52 Add preconditions in writer and string functions 2016-09-03 23:37:00 +08:00
niukuo
250cf666d3 fix wrong length in remote schema
Change-Id: Ia96ddf5746f1c18968e9e086f17fe4a24b8480d7
2016-08-31 16:26:27 +08:00
Janusz Chorko
862c39be37 Explicitly disable copy assignment operator 2016-08-26 21:26:50 +02:00
Janusz Chorko
3b2441b87f Removed non-compiling assignment operator. Fixed #718 2016-08-26 21:17:38 +02:00
Milo Yip
17254e090e Version 1.1.0
Change version numbers
Fixed some document linkage
Fix #648
2016-08-25 14:35:17 +08:00
Jordi Mallach
323a0dce43 Fix builds on x32 platform.
From the Debian wiki: https://wiki.debian.org/X32Port

X32 is an ABI for amd64/x86_64 CPUs using 32-bit integers, longs
and pointers. The idea is to combine the smaller memory and cache
footprint from 32-bit data types with the larger register set of
x86_64. The 64-bit registers can make computation more efficient,
and with 8 additional registers available, there is less pressure
compared to i386/i686.

rapidjson makes an incorrect assumption in a check for 64 bit
platforms, and uses __LP64__ exclusively. This fix adds an
additional check for __x86_64__ && __ILP32__ defines, as a very
conservative fix. However, the usage of __LP64__ would be a problem
for other "mixed" applications like ARM ILP32, so a better detection
scheme might be needed in the future.
2016-08-01 14:25:50 +02:00
Jamie Seward
78a7ecb946 Add std::string overload to PrettyWriter::Key() when RAPIDJSON_HAS_STDSTRING is #defined
Only String() has the std::string overload currently.
2016-07-26 22:35:46 -07:00
Milo Yip
332b61fe41 Handle malloc() fail in PoolAllocator
Fix #682
2016-07-21 17:25:17 +08:00
Milo Yip
2f751650e2 Merge pull request #690 from fuzhufang/master
optimize FindMember  when use std::string
2016-07-21 11:37:33 +08:00
Milo Yip
db6a6f3f64 Add Flush() for all value types
Fixes #684
2016-07-21 09:33:00 +08:00
fuzhufang
b67ff2fb11 if define RAPIDJSON_HAS_STDSTRING, FindMember use std::string, but it
also use internal::StrLen to get the string lengtht,
when it call FindMember(StringRef(name)).
Now use GenericValue construct it, then can use the std::string.size.
now it will be faster.
2016-07-14 17:50:48 +08:00
yiteng.nyt
8c43554de6 fix rapidjson::value::Get<std::string>() may returns wrong data
Change-Id: Ia7325edb437e3039e29223d0ecc4d9c83d824bc0
2016-07-11 12:38:10 +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
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
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
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
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
89f6b8a380 Clang doesn't like the C-style casts in nmmintrin.h 2016-06-13 07:24:26 -07:00
Milo Yip
fee5190def Fix a clang warning 2016-06-13 09:34:47 +08: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
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
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
0fe08c222f Fix english error message gramma
Fix #606
2016-04-19 16:22:24 +08:00
Milo Yip
a6571d504a Combine objectDependices and objectRequired into propertyExist array 2016-04-19 15:10:28 +08:00
Milo Yip
f586edd33d Fix required for duplicated keys
Fix #608
2016-04-19 15:06:41 +08:00
Milo Yip
be352d9548 Fix a bug in regex
Due to dereferencing a pointer which may be invalidated
2016-04-17 11:59:09 +08:00
Milo Yip
01aeebf9bf Improve reader coverage by removing a default case 2016-04-17 09:47:29 +08:00
Milo Yip
a28e4befed Improve coverage of Regex by removing default case. 2016-04-17 09:34:04 +08:00
Milo Yip
ba0a137b9c Remove unnecessary code in GenericSchemaDocument::CreateSchemaRecursive() 2016-04-17 09:17:05 +08:00
Milo Yip
cb2f340d55 Remove ISchemaStateFactory::ReallocState() 2016-04-17 09:11:00 +08:00
Milo Yip
e7149d6659 Fix memory leak for invalid regex 2016-04-17 00:58:32 +08:00
Milo Yip
26e69ffde9 Fix a bug in schema minimum/maximum keywords for 64-bit integer 2016-04-17 00:48:02 +08:00
Milo Yip
ecd8fa3437 Improve coverage of regex 2016-04-16 23:04:40 +08:00
Milo Yip
fdd443120f Move break into same line to make coverage happy 2016-04-16 22:09:23 +08:00
Milo Yip
75d0e4ff65 Use single Peek() in SkipWhitespace
Fix #594
2016-04-07 00:47:26 +08:00
Milo Yip
12425693ba Revert formatting of enum 2016-04-06 23:33:26 +08:00
Milo Yip
44d114f3ee Supress VC C4512 warning 2016-04-06 00:47:16 +08:00
Milo Yip
be5a886f8f Fix clang compilation error 2016-04-06 00:34:45 +08:00
Milo Yip
689be10891 Fix a compilation error 2016-04-06 00:11:49 +08:00
Milo Yip
35ccca8b74 Try to fix VC warning C4512 2016-04-05 23:56:50 +08:00
Milo Yip
8991037ecd Revert using of static const back to enum due to gcc error 2016-04-05 23:26:08 +08:00
Milo Yip
c843a2655b Try to fix all /W4 warnings in VC2015 2016-04-04 15:01:34 +08:00
Jarred Nicholls
926d7ffcc8 Later clang compilers will warn on float -> double promotion because it can add precision. In the context of RapidJSON – especially with its float methods on GenericValue – I think this warning holds no water and should be ignored.
Trim whitespace off the end of various lines.

Added an additional NumberStream specialization that will always perform a TakePush() even when just Take() is called. This supports RawNumber parsing by pushing onto our StackStream particular parts of the number that currently aren't captured because of full precision double parsing, such as the negative sign, scientific number exponents, etc.

RawNumber parsing fails with input streams that don't have copy optimization, such as the BasicIStreamWrapper stream. To work around this, instead do the Transcode copy operation by reading from a UTF8 StringStream instead of the original InputStream. Since the NumberStream downcasts all input Ch into chars, we know we're dealing with UTF8/ASCII compatible stack characters during the Transcoding.
2016-03-29 15:44:30 -04:00