summaryrefslogtreecommitdiffstats
path: root/src/schema_features.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:23:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:23:18 +0000
commit16527d165de55f2727f55b752b30d44a7e61e927 (patch)
tree0840ee6e0e109a9e85f0d80ff36f92587c6a5538 /src/schema_features.c
parentReleasing progress-linux version 2.1.30-2.1~progress7.99u1. (diff)
downloadlibyang2-16527d165de55f2727f55b752b30d44a7e61e927.tar.xz
libyang2-16527d165de55f2727f55b752b30d44a7e61e927.zip
Merging upstream version 2.1.148.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/schema_features.c')
-rw-r--r--src/schema_features.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/schema_features.c b/src/schema_features.c
index dca998e..b4273df 100644
--- a/src/schema_features.c
+++ b/src/schema_features.c
@@ -411,7 +411,7 @@ lys_compile_iffeature(const struct ly_ctx *ctx, const struct lysp_qname *qname,
LY_ARRAY_CREATE_RET(ctx, iff->features, f_size, LY_EMEM);
iff->expr = calloc((j = (expr_size / IFF_RECORDS_IN_BYTE) + ((expr_size % IFF_RECORDS_IN_BYTE) ? 1 : 0)), sizeof *iff->expr);
stack.stack = malloc(expr_size * sizeof *stack.stack);
- LY_CHECK_ERR_GOTO(!stack.stack || !iff->expr, LOGMEM(ctx); rc = LY_EMEM, error);
+ LY_CHECK_ERR_GOTO(!stack.stack || !iff->expr, LOGMEM(ctx); rc = LY_EMEM, cleanup);
stack.size = expr_size;
f_size--; expr_size--; /* used as indexes from now */
@@ -473,7 +473,7 @@ lys_compile_iffeature(const struct ly_ctx *ctx, const struct lysp_qname *qname,
LOGVAL(ctx, LYVE_SYNTAX_YANG, "Invalid value \"%s\" of if-feature - unable to find feature \"%.*s\".",
qname->str, (int)(j - i), &c[i]);
rc = LY_EVALID;
- goto error;
+ goto cleanup;
}
iff->features[f_size] = f;
LY_ARRAY_INCREMENT(iff->features);
@@ -489,14 +489,16 @@ lys_compile_iffeature(const struct ly_ctx *ctx, const struct lysp_qname *qname,
/* not all expected operators and operands found */
LOGVAL(ctx, LYVE_SYNTAX_YANG, "Invalid value \"%s\" of if-feature - processing error.", qname->str);
rc = LY_EINT;
- } else {
- rc = LY_SUCCESS;
}
-error:
- /* cleanup */
+cleanup:
+ if (rc) {
+ LY_ARRAY_FREE(iff->features);
+ iff->features = NULL;
+ free(iff->expr);
+ iff->expr = NULL;
+ }
iff_stack_clean(&stack);
-
return rc;
}