fix(src): avoid possible infinite loop in LoadAll().

Leave at first empty root.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
This commit is contained in:
Federico Di Pierro
2024-09-12 14:16:15 +02:00
committed by Jesse Beder
parent da82fd982c
commit bc67157109

View File

@@ -53,7 +53,7 @@ std::vector<Node> LoadAll(std::istream& input) {
Parser parser(input);
while (true) {
NodeBuilder builder;
if (!parser.HandleNextDocument(builder)) {
if (!parser.HandleNextDocument(builder) || builder.Root().IsNull()) {
break;
}
docs.push_back(builder.Root());