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
be352d95
Commit
be352d95
authored
8 years ago
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bug in regex
Due to dereferencing a pointer which may be invalidated
parent
8f4e99b2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
regex.h
include/rapidjson/internal/regex.h
+4
-4
regextest.cpp
test/unittest/regextest.cpp
+5
-0
No files found.
include/rapidjson/internal/regex.h
View file @
be352d95
...
...
@@ -468,17 +468,17 @@ private:
static
SizeType
Min
(
SizeType
a
,
SizeType
b
)
{
return
a
<
b
?
a
:
b
;
}
void
CloneTopOperand
(
Stack
<
Allocator
>&
operandStack
)
{
const
Frag
*
src
=
operandStack
.
template
Top
<
Frag
>
();
SizeType
count
=
stateCount_
-
src
->
minIndex
;
// Assumes top operand contains states in [src->minIndex, stateCount_)
const
Frag
src
=
*
operandStack
.
template
Top
<
Frag
>
();
// Copy constructor to prevent invalidation
SizeType
count
=
stateCount_
-
src
.
minIndex
;
// Assumes top operand contains states in [src->minIndex, stateCount_)
State
*
s
=
states_
.
template
Push
<
State
>
(
count
);
memcpy
(
s
,
&
GetState
(
src
->
minIndex
),
count
*
sizeof
(
State
));
memcpy
(
s
,
&
GetState
(
src
.
minIndex
),
count
*
sizeof
(
State
));
for
(
SizeType
j
=
0
;
j
<
count
;
j
++
)
{
if
(
s
[
j
].
out
!=
kRegexInvalidState
)
s
[
j
].
out
+=
count
;
if
(
s
[
j
].
out1
!=
kRegexInvalidState
)
s
[
j
].
out1
+=
count
;
}
*
operandStack
.
template
Push
<
Frag
>
()
=
Frag
(
src
->
start
+
count
,
src
->
out
+
count
,
src
->
minIndex
+
count
);
*
operandStack
.
template
Push
<
Frag
>
()
=
Frag
(
src
.
start
+
count
,
src
.
out
+
count
,
src
.
minIndex
+
count
);
stateCount_
+=
count
;
}
...
...
This diff is collapsed.
Click to expand it.
test/unittest/regextest.cpp
View file @
be352d95
...
...
@@ -584,4 +584,9 @@ TEST(Regex, Issue538) {
EXPECT_TRUE
(
re
.
IsValid
());
}
TEST
(
Regex
,
Issue583
)
{
Regex
re
(
"[0-9]{99999}"
);
ASSERT_TRUE
(
re
.
IsValid
());
}
#undef EURO
This diff is collapsed.
Click to expand it.
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