From 1c67b948b6745e1aa6deeeea8473740aeea0e315 Mon Sep 17 00:00:00 2001 From: Mikhail Khachayants Date: Sun, 20 Oct 2024 13:47:54 +0300 Subject: [PATCH] Fix stack overflow for unresolved references --- include/valijson/schema_parser.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/valijson/schema_parser.hpp b/include/valijson/schema_parser.hpp index fef97b3..7359b77 100644 --- a/include/valijson/schema_parser.hpp +++ b/include/valijson/schema_parser.hpp @@ -1040,13 +1040,14 @@ private: resolveThenPopulateSchema(rootSchema, newRootNode, referencedAdapter, subschema, {}, actualJsonPointer, fetchDoc, parentSchema, ownName, docCache, schemaCache); - } else { + } else if (!actualJsonPointer.empty()) { const AdapterType &referencedAdapter = internal::json_pointer::resolveJsonPointer(rootNode, actualJsonPointer); - // TODO: Need to detect degenerate circular references resolveThenPopulateSchema(rootSchema, rootNode, referencedAdapter, subschema, {}, actualJsonPointer, fetchDoc, parentSchema, ownName, docCache, schemaCache); + } else { + throwRuntimeError("Cannot resolve reference \"" + jsonRef + "\"."); } }