Skip to content

Commit d2fbca8

Browse files
committed
printer lyb BUGFIX avoid invalid arg error
1 parent 82ab253 commit d2fbca8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/printer_lyb.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,12 @@ lyb_print_header(struct ly_out *out, const struct ly_ctx *ctx)
538538

539539
LY_CHECK_RET(ly_write_(out, (char *)&byte, sizeof byte));
540540

541-
/* context hash */
542-
hash = ly_ctx_get_modules_hash(ctx);
541+
/* context hash, if not printing empty data */
542+
if (ctx) {
543+
hash = ly_ctx_get_modules_hash(ctx);
544+
} else {
545+
hash = 0;
546+
}
543547
LY_CHECK_RET(ly_write_(out, (char *)&hash, sizeof hash));
544548

545549
return LY_SUCCESS;

0 commit comments

Comments
 (0)