diff --git a/src/coders/BasicParser.inl b/src/coders/BasicParser.inl index 7af27fe5..796205b2 100644 --- a/src/coders/BasicParser.inl +++ b/src/coders/BasicParser.inl @@ -139,8 +139,12 @@ void BasicParser::skipLine() { template void BasicParser::skipEmptyLines() { + if (!hasNext()) { + return; + } + size_t initpos = pos; skipWhitespace(); - pos = linestart; + pos = std::max(initpos, linestart); } template diff --git a/src/coders/yaml.cpp b/src/coders/yaml.cpp index 33eab3a5..f400f667 100644 --- a/src/coders/yaml.cpp +++ b/src/coders/yaml.cpp @@ -270,6 +270,10 @@ dv::value Parser::parseArray(int indent) { dv::value object = dv::object(); object[std::string(name)] = parseFullValue(next_indent); skipEmptyLines(); + if (!hasNext()) { + list.add(std::move(object)); + break; + } next_indent = countIndent(); if (next_indent > indent) { pos = linestart;