From 0f5f8c9aa73303875f03cd529e8496a2d44735ce Mon Sep 17 00:00:00 2001 From: Ilyes Ben Hamouda Date: Thu, 7 Sep 2023 08:46:33 +0200 Subject: [PATCH] printer json BUGFIX nested union value print Fix an infinite loop in json_print_value() when resolved type of a union member is also union. Fixes: 183b911ec920 ("printer json BUGFIX union realtype value print") Signed-off-by: Ilyes Ben Hamouda --- src/printer_json.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/printer_json.c b/src/printer_json.c index 165dfab5d..312e30df1 100644 --- a/src/printer_json.c +++ b/src/printer_json.c @@ -363,7 +363,8 @@ json_print_value(struct jsonpr_ctx *pctx, const struct ly_ctx *ctx, const struct switch (basetype) { case LY_TYPE_UNION: /* use the resolved type */ - basetype = val->subvalue->value.realtype->basetype; + val = &val->subvalue->value; + basetype = val->realtype->basetype; goto print_val; case LY_TYPE_BINARY: