Skip to content

Commit 404ed52

Browse files
committed
schema compile node BUGFIX free on error
1 parent 4a48d8e commit 404ed52

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/schema_compile_node.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,10 @@ lysc_range_dup(struct lysc_ctx *ctx, const struct lysc_range *orig, struct ly_se
388388
return dup;
389389

390390
error:
391-
free(dup);
392-
/* set but not used due to the return type */
393-
(void) ret;
391+
if (dup) {
392+
lysc_range_free(ctx->ctx, dup);
393+
free(dup);
394+
}
394395
return NULL;
395396
}
396397

src/tree_schema_free.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -808,14 +808,7 @@ lysc_ident_free(const struct ly_ctx *ctx, struct lysc_ident *ident)
808808
FREE_ARRAY(ctx, ident->exts, lysc_ext_instance_free);
809809
}
810810

811-
/**
812-
* @brief Free the compiled range structure.
813-
*
814-
* @param[in] ctx Context to use.
815-
* @param[in,out] range Compiled range structure to be freed.
816-
* Since the structure is typically part of the sized array, the structure itself is not freed.
817-
*/
818-
static void
811+
void
819812
lysc_range_free(const struct ly_ctx *ctx, struct lysc_range *range)
820813
{
821814
LY_ARRAY_FREE(range->parts);

src/tree_schema_free.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ void lysc_ext_instance_free(const struct ly_ctx *ctx, struct lysc_ext_instance *
129129
*/
130130
void lysc_iffeature_free(const struct ly_ctx *ctx, struct lysc_iffeature *iff);
131131

132+
/**
133+
* @brief Free the compiled range structure.
134+
*
135+
* @param[in] ctx Context to use.
136+
* @param[in,out] range Compiled range structure to be freed.
137+
* Since the structure is typically part of the sized array, the structure itself is not freed.
138+
*/
139+
void lysc_range_free(const struct ly_ctx *ctx, struct lysc_range *range);
140+
132141
/**
133142
* @brief Free a compiled pattern.
134143
*

0 commit comments

Comments
 (0)