There is a an assertion in `expr_evaluate_unary` that checks that the operand of the unary operation is not itself a unary expression. Add a check to `byteorder_conversion` to ensure that this is the case by removing an existing unary operation, rather than adding a second one. Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx> --- src/evaluate.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/evaluate.c b/src/evaluate.c index 17a437bd6530..77781f0ec6de 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -195,7 +195,12 @@ static int byteorder_conversion(struct eval_ctx *ctx, struct expr **expr, if (expr_is_constant(*expr) || div_round_up((*expr)->len, BITS_PER_BYTE) < 2) (*expr)->byteorder = byteorder; - else { + else if ((*expr)->etype == EXPR_UNARY) { + /* Remove existing conversion */ + struct expr *unary = *expr; + *expr = expr_get((*expr)->arg); + expr_free(unary); + } else { op = byteorder_conversion_op(*expr, byteorder); *expr = unary_expr_alloc(&(*expr)->location, op, *expr); if (expr_evaluate(ctx, expr) < 0) -- 2.39.2