Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
ecba08e2
Commit
ecba08e2
authored
Sep 24, 2008
by
jbeder
Browse files
Fixed infinite loop bug having to do with simple keys when we hit an unexpected EOF.
parent
d51888bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
src/scanner.h
src/scanner.h
+1
-1
src/simplekey.cpp
src/simplekey.cpp
+9
-3
yaml-reader/tests/test.yaml
yaml-reader/tests/test.yaml
+1
-3
No files found.
src/scanner.h
View file @
ecba08e2
...
@@ -33,7 +33,7 @@ namespace YAML
...
@@ -33,7 +33,7 @@ namespace YAML
// checking input
// checking input
void
InsertSimpleKey
();
void
InsertSimpleKey
();
bool
VerifySimpleKey
();
bool
VerifySimpleKey
(
bool
force
=
false
);
void
VerifyAllSimpleKeys
();
void
VerifyAllSimpleKeys
();
bool
IsWhitespaceToBeEaten
(
char
ch
);
bool
IsWhitespaceToBeEaten
(
char
ch
);
...
...
src/simplekey.cpp
View file @
ecba08e2
...
@@ -50,7 +50,8 @@ namespace YAML
...
@@ -50,7 +50,8 @@ namespace YAML
// VerifySimpleKey
// VerifySimpleKey
// . Determines whether the latest simple key to be added is valid,
// . Determines whether the latest simple key to be added is valid,
// and if so, makes it valid.
// and if so, makes it valid.
bool
Scanner
::
VerifySimpleKey
()
// . If 'force' is true, then we'll pop no matter what (whether we can verify it or not).
bool
Scanner
::
VerifySimpleKey
(
bool
force
)
{
{
m_isLastKeyValid
=
false
;
m_isLastKeyValid
=
false
;
if
(
m_simpleKeys
.
empty
())
if
(
m_simpleKeys
.
empty
())
...
@@ -60,8 +61,11 @@ namespace YAML
...
@@ -60,8 +61,11 @@ namespace YAML
SimpleKey
key
=
m_simpleKeys
.
top
();
SimpleKey
key
=
m_simpleKeys
.
top
();
// only validate if we're in the correct flow level
// only validate if we're in the correct flow level
if
(
key
.
flowLevel
!=
m_flowLevel
)
if
(
key
.
flowLevel
!=
m_flowLevel
)
{
if
(
force
)
m_simpleKeys
.
pop
();
return
false
;
return
false
;
}
m_simpleKeys
.
pop
();
m_simpleKeys
.
pop
();
...
@@ -94,9 +98,11 @@ namespace YAML
...
@@ -94,9 +98,11 @@ namespace YAML
return
isValid
;
return
isValid
;
}
}
// VerifyAllSimplyKeys
// . Pops all simple keys (with checking, but if we can't verify one, then pop it anyways).
void
Scanner
::
VerifyAllSimpleKeys
()
void
Scanner
::
VerifyAllSimpleKeys
()
{
{
while
(
!
m_simpleKeys
.
empty
())
while
(
!
m_simpleKeys
.
empty
())
VerifySimpleKey
();
VerifySimpleKey
(
true
);
}
}
}
}
yaml-reader/tests/test.yaml
View file @
ecba08e2
-
it's just
bad YAML
:
[
-
one thing
\ No newline at end of file
-
after another
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