Skip to content

Commit

Permalink
data tree BUGFIX allow parsing empty data
Browse files Browse the repository at this point in the history
They are valid for XML when they need to be
validated and default nodes added.

Fixes CESNET#1357
  • Loading branch information
michalvasko committed Jan 25, 2021
1 parent 6f2b12a commit 5a557a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ lyp_mmap(struct ly_ctx *ctx, int fd, size_t addsize, size_t *length, void **addr
int
lyp_munmap(void *addr, size_t length)
{
if (!addr) {
/* nothing to unmap */
return 0;
}

return munmap(addr, length);
}

Expand Down
4 changes: 1 addition & 3 deletions src/tree_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ lyd_parse_(struct ly_ctx *ctx, const struct lyd_node *rpc_act, const char *data,
struct lyd_node *result = NULL;
int xmlopt = LYXML_PARSE_MULTIROOT;

if (!ctx || !data) {
if (!ctx) {
LOGARG;
return NULL;
}
Expand Down Expand Up @@ -1069,8 +1069,6 @@ lyd_parse_fd_(struct ly_ctx *ctx, int fd, LYD_FORMAT format, int options, va_lis
if (lyp_mmap(ctx, fd, 0, &length, (void **)&data)) {
LOGERR(ctx, LY_ESYS, "Mapping file descriptor into memory failed (%s()).", __func__);
return NULL;
} else if (!data) {
return NULL;
}

ret = lyd_parse_data_(ctx, data, format, options, ap);
Expand Down

0 comments on commit 5a557a0

Please sign in to comment.