summaryrefslogtreecommitdiffstats
path: root/contrib/libucl/ucl_schema.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-03-14 19:03:40 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-03-14 19:03:40 +0000
commit7c95a5baa0901af763a09ea684fb07da95f9d06c (patch)
treec813f3c1f5529bd37144fd515f7c20e8832a1805 /contrib/libucl/ucl_schema.c
parentea4b2ff1dbbd39d0d291bf7bcb2e8fba01ad9eab (diff)
downloadrspamd-7c95a5baa0901af763a09ea684fb07da95f9d06c.tar.gz
rspamd-7c95a5baa0901af763a09ea684fb07da95f9d06c.zip
[Minor] Backport some fixes from libucl
Diffstat (limited to 'contrib/libucl/ucl_schema.c')
-rw-r--r--contrib/libucl/ucl_schema.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/contrib/libucl/ucl_schema.c b/contrib/libucl/ucl_schema.c
index d11d66909..68f01187e 100644
--- a/contrib/libucl/ucl_schema.c
+++ b/contrib/libucl/ucl_schema.c
@@ -244,20 +244,22 @@ ucl_schema_validate_object (const ucl_object_t *schema,
/* Additional properties */
if (!allow_additional || additional_schema != NULL) {
/* Check if we have exactly the same properties in schema and object */
- iter = NULL;
+ iter = ucl_object_iterate_new (obj);
prop = ucl_object_lookup (schema, "properties");
- while ((elt = ucl_object_iterate (obj, &iter, true)) != NULL) {
+ while ((elt = ucl_object_iterate_safe (iter, true)) != NULL) {
found = ucl_object_lookup (prop, ucl_object_key (elt));
if (found == NULL) {
/* Try patternProperties */
- piter = NULL;
pat = ucl_object_lookup (schema, "patternProperties");
- while ((pelt = ucl_object_iterate (pat, &piter, true)) != NULL) {
+ piter = ucl_object_iterate_new (pat);
+ while ((pelt = ucl_object_iterate_safe (piter, true)) != NULL) {
found = ucl_schema_test_pattern (obj, ucl_object_key (pelt), true);
if (found != NULL) {
break;
}
}
+ ucl_object_iterate_free (piter);
+ piter = NULL;
}
if (found == NULL) {
if (!allow_additional) {
@@ -276,6 +278,8 @@ ucl_schema_validate_object (const ucl_object_t *schema,
}
}
}
+ ucl_object_iterate_free (iter);
+ iter = NULL;
}
/* Required properties */
if (required != NULL) {