diff --git a/src/json-validator.cpp b/src/json-validator.cpp index 88278a0b61aadfb726f49b7ab597f2d5410e39b8..a0a81d9fc59520ccda2840ca0621cfd8c0ae4461 100644 --- a/src/json-validator.cpp +++ b/src/json-validator.cpp @@ -36,14 +36,16 @@ static void loader(const json_uri &uri, json &schema) s_def = schema_get_definitions_schema(uri.url().c_str()); if (!s_def) - return; + throw std::invalid_argument("could not find " + uri.url()); + str = blobmsg_format_json(s_def->definitions, true); if (!str) - return; + throw std::invalid_argument("could not allocate memory for definition"); schema = json::parse(str); + free(str); } diff --git a/src/schema.cpp b/src/schema.cpp index f7846e123b469c3dcceea137c9c106bccaedc07e..5866d0dca691fc258358833fb3f09be71b07f0ce 100644 --- a/src/schema.cpp +++ b/src/schema.cpp @@ -96,7 +96,7 @@ static void schema_flush_definitions(void) { struct schema_definition *s_def, *tmp; - dbg("cleaning all schema objects\n"); + dbg("cleaning all schema definitions\n"); avl_for_each_element_safe(&s_ctx.schema_definitions, s_def, avl, tmp) { avl_delete(&s_ctx.schema_objects, &s_def->avl); @@ -331,12 +331,13 @@ schema_setup(void) unsigned int i; glob_t gl; + avl_init(&s_ctx.schema_objects, avl_strcmp, false, NULL); + avl_init(&s_ctx.schema_definitions, avl_strcmp, false, NULL); + /* setup docs */ if (glob(JSON_SCHEMA_DIR "/*.json", 0, NULL, &gl)) return; - avl_init(&s_ctx.schema_objects, avl_strcmp, false, NULL); - for (i = 0; i < gl.gl_pathc; i++) { dbg("doc path = %s\n", gl.gl_pathv[i]); schema_setup_documents(gl.gl_pathv[i]);