mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Fix SEGV in ostream_wrapper
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user