Fix writeCommentBeforeValue() iter deref

fixes #649
This commit is contained in:
Christopher Dunn 2017-08-28 08:42:20 -05:00
parent 90591c70cd
commit d830c0ab94

View File

@ -582,7 +582,7 @@ void StyledWriter::writeCommentBeforeValue(const Value& root) {
while (iter != comment.end()) { while (iter != comment.end()) {
document_ += *iter; document_ += *iter;
if (*iter == '\n' && if (*iter == '\n' &&
(iter != comment.end() && *(iter + 1) == '/')) ((iter+1) != comment.end() && *(iter + 1) == '/'))
writeIndent(); writeIndent();
++iter; ++iter;
} }
@ -798,7 +798,7 @@ void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
while (iter != comment.end()) { while (iter != comment.end()) {
*document_ << *iter; *document_ << *iter;
if (*iter == '\n' && if (*iter == '\n' &&
(iter != comment.end() && *(iter + 1) == '/')) ((iter+1) != comment.end() && *(iter + 1) == '/'))
// writeIndent(); // would include newline // writeIndent(); // would include newline
*document_ << indentString_; *document_ << indentString_;
++iter; ++iter;
@ -1086,7 +1086,7 @@ void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {
while (iter != comment.end()) { while (iter != comment.end()) {
*sout_ << *iter; *sout_ << *iter;
if (*iter == '\n' && if (*iter == '\n' &&
(iter != comment.end() && *(iter + 1) == '/')) ((iter+1) != comment.end() && *(iter + 1) == '/'))
// writeIndent(); // would write extra newline // writeIndent(); // would write extra newline
*sout_ << indentString_; *sout_ << indentString_;
++iter; ++iter;