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
396a9705
Commit
396a9705
authored
Mar 22, 2014
by
Jesse Beder
Browse files
Fix SEGV in ostream_wrapper
parent
db82302e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
5 deletions
+27
-5
src/ostream_wrapper.cpp
src/ostream_wrapper.cpp
+10
-3
test/CMakeLists.txt
test/CMakeLists.txt
+2
-2
test/ostream_wrapper_test.cpp
test/ostream_wrapper_test.cpp
+15
-0
No files found.
src/ostream_wrapper.cpp
View file @
396a9705
...
...
@@ -4,7 +4,12 @@
namespace
YAML
{
ostream_wrapper
::
ostream_wrapper
()
:
m_pStream
(
0
),
m_pos
(
0
),
m_row
(
0
),
m_col
(
0
),
m_comment
(
false
)
{}
:
m_buffer
(
1
,
'\0'
),
m_pStream
(
0
),
m_pos
(
0
),
m_row
(
0
),
m_col
(
0
),
m_comment
(
false
)
{}
ostream_wrapper
::
ostream_wrapper
(
std
::
ostream
&
stream
)
:
m_pStream
(
&
stream
),
m_pos
(
0
),
m_row
(
0
),
m_col
(
0
),
m_comment
(
false
)
{}
...
...
@@ -19,8 +24,9 @@ void ostream_wrapper::write(const std::string& str) {
std
::
copy
(
str
.
begin
(),
str
.
end
(),
&
m_buffer
[
m_pos
]);
}
for
(
std
::
size_t
i
=
0
;
i
<
str
.
size
();
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
str
.
size
();
i
++
)
{
update_pos
(
str
[
i
]);
}
}
void
ostream_wrapper
::
write
(
const
char
*
str
,
std
::
size_t
size
)
{
...
...
@@ -31,8 +37,9 @@ void ostream_wrapper::write(const char* str, std::size_t size) {
std
::
copy
(
str
,
str
+
size
,
&
m_buffer
[
m_pos
]);
}
for
(
std
::
size_t
i
=
0
;
i
<
size
;
i
++
)
for
(
std
::
size_t
i
=
0
;
i
<
size
;
i
++
)
{
update_pos
(
str
[
i
]);
}
}
void
ostream_wrapper
::
update_pos
(
char
ch
)
{
...
...
test/CMakeLists.txt
View file @
396a9705
add_subdirectory
(
gtest-1.7.0
)
include_directories
(
gtest-1.7.0/include
)
file
(
GLOB test_headers [a-z]*.h
)
file
(
GLOB test_sources [a-z]*.cpp
)
file
(
GLOB test_headers [a-z
_
]*.h
)
file
(
GLOB test_sources [a-z
_
]*.cpp
)
file
(
GLOB test_core_sources core/[a-z]*.cpp
)
list
(
APPEND test_sources
${
test_core_sources
}
)
...
...
test/ostream_wrapper_test.cpp
0 → 100644
View file @
396a9705
#include "yaml-cpp/ostream_wrapper.h"
#include "gtest/gtest.h"
namespace
{
class
OstreamWrapperTest
:
public
::
testing
::
Test
{
protected:
};
// Tests that the Foo::Bar() method does Abc.
TEST_F
(
OstreamWrapperTest
,
ConstructNoWrite
)
{
YAML
::
ostream_wrapper
wrapper
;
EXPECT_STREQ
(
""
,
wrapper
.
str
());
}
}
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