diff --git a/src/parser.c b/src/parser.c index db65bb808..e7089b550 100644 --- a/src/parser.c +++ b/src/parser.c @@ -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); } diff --git a/src/tree_data.c b/src/tree_data.c index c3a2ece0b..566bf33cf 100644 --- a/src/tree_data.c +++ b/src/tree_data.c @@ -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; } @@ -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);