Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
69ca7487
Commit
69ca7487
authored
Jun 27, 2014
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Manually merge the segfault fix from main branch and fix several unit tests about error code
parent
b0059483
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
reader.h
include/rapidjson/reader.h
+8
-0
readertest.cpp
test/unittest/readertest.cpp
+5
-7
No files found.
include/rapidjson/reader.h
View file @
69ca7487
...
...
@@ -269,12 +269,16 @@ public:
case
'['
:
ParseArray
<
parseFlags
>
(
is
,
handler
);
break
;
default
:
RAPIDJSON_PARSE_ERROR_NORETURN
(
kParseErrorDocumentRootNotObjectOrArray
,
is
.
Tell
());
}
if
(
HasParseError
())
goto
out
;
SkipWhitespace
(
is
);
if
(
is
.
Peek
()
!=
'\0'
)
RAPIDJSON_PARSE_ERROR_NORETURN
(
kParseErrorDocumentRootNotSingular
,
is
.
Tell
());
}
out
:
stack_
.
Clear
();
return
!
HasParseError
();
}
...
...
@@ -440,6 +444,8 @@ private:
if
(
parseFlags
&
kParseInsituFlag
)
{
Ch
*
head
=
s
.
PutBegin
();
ParseStringToStream
<
parseFlags
,
SourceEncoding
,
SourceEncoding
>
(
s
,
s
);
if
(
HasParseError
())
return
;
size_t
length
=
s
.
PutEnd
(
head
)
-
1
;
RAPIDJSON_ASSERT
(
length
<=
0xFFFFFFFF
);
handler
.
String
((
typename
TargetEncoding
::
Ch
*
)
head
,
SizeType
(
length
),
false
);
...
...
@@ -447,6 +453,8 @@ private:
else
{
StackStream
stackStream
(
stack_
);
ParseStringToStream
<
parseFlags
,
SourceEncoding
,
TargetEncoding
>
(
s
,
stackStream
);
if
(
HasParseError
())
return
;
handler
.
String
(
stack_
.
template
Pop
<
typename
TargetEncoding
::
Ch
>
(
stackStream
.
length_
),
stackStream
.
length_
-
1
,
true
);
}
is
=
s
;
// Restore is
...
...
test/unittest/readertest.cpp
View file @
69ca7487
...
...
@@ -335,8 +335,8 @@ TEST(Reader, ParseString_Error) {
TEST_STRING_ERROR
(
kParseErrorStringUnicodeEscapeInvalidHex
,
"[
\"\\
uABCG
\"
]"
);
// The surrogate pair in string is invalid.
TEST_STRING_ERROR
(
kParseErrorStringUnicode
EscapeInvalidHex
,
"[
\"\\
uD800X
\"
]"
);
TEST_STRING_ERROR
(
kParseErrorStringUnicode
EscapeInvalidHex
,
"[
\"\\
uD800
\\
uFFFF
\"
]"
);
TEST_STRING_ERROR
(
kParseErrorStringUnicode
SurrogateInvalid
,
"[
\"\\
uD800X
\"
]"
);
TEST_STRING_ERROR
(
kParseErrorStringUnicode
SurrogateInvalid
,
"[
\"\\
uD800
\\
uFFFF
\"
]"
);
// Missing a closing quotation mark in string.
TEST_STRING_ERROR
(
kParseErrorStringMissQuotationMark
,
"[
\"
Test]"
);
...
...
@@ -352,7 +352,7 @@ TEST(Reader, ParseString_Error) {
e
[
2
]
=
c
;
ParseErrorCode
error
=
TestString
(
e
);
EXPECT_EQ
(
kParseErrorStringInvalidEncoding
,
error
);
if
(
error
!=
kParseError
None
)
if
(
error
!=
kParseError
StringInvalidEncoding
)
std
::
cout
<<
(
unsigned
)(
unsigned
char
)
c
<<
std
::
endl
;
}
}
...
...
@@ -443,8 +443,8 @@ TEST(Reader, ParseArray_Error) {
}
// Missing a comma or ']' after an array element.
TEST_ARRAY_ERROR
(
kParseErrorArrayMissCommaOrSquareBracket
,
"["
);
TEST_ARRAY_ERROR
(
kParseErrorArrayMissCommaOrSquareBracket
,
"[}"
);
TEST_ARRAY_ERROR
(
kParseErrorArrayMissCommaOrSquareBracket
,
"[
1
"
);
TEST_ARRAY_ERROR
(
kParseErrorArrayMissCommaOrSquareBracket
,
"[
1
}"
);
TEST_ARRAY_ERROR
(
kParseErrorArrayMissCommaOrSquareBracket
,
"[1 2]"
);
#undef TEST_ARRAY_ERROR
...
...
@@ -590,8 +590,6 @@ TEST(Reader, ParseObject_Error) {
TEST_ERROR
(
kParseErrorObjectMissColon
,
"{
\"
a
\"
,1}"
);
// Must be a comma or '}' after an object member
TEST_ERROR
(
kParseErrorObjectMissCommaOrCurlyBracket
,
"{"
);
TEST_ERROR
(
kParseErrorObjectMissCommaOrCurlyBracket
,
"{]"
);
TEST_ERROR
(
kParseErrorObjectMissCommaOrCurlyBracket
,
"{
\"
a
\"
:1]"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment