From: =?utf-8?b?0L3QsNCx?= <nabijaczleweli@nabijaczleweli.xyz>
Date: Fri, 31 Jan 2025 13:18:22 +0100
Subject: Fix length accounting in format_expr() (Closes: #807183)

Matches format_seg() now
---
 libdisasm/x86_format.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libdisasm/x86_format.c b/libdisasm/x86_format.c
index b5b47e3..2b6944c 100644
--- a/libdisasm/x86_format.c
+++ b/libdisasm/x86_format.c
@@ -161,6 +161,7 @@ static void get_operand_regtype_str( int regtype, char *str, int len )
 static int format_expr( x86_ea_t *ea, char *buf, int len,
                         enum x86_asm_format format ) {
         char str[MAX_OP_STRING];
+        int len_orig = len;
 
         if ( format == att_syntax ) {
 		if (ea->base.name[0] || ea->index.name[0] || ea->scale) {
@@ -279,7 +280,7 @@ static int format_expr( x86_ea_t *ea, char *buf, int len,
                 STRNCAT( buf, "]", len );
         }
 
-        return( strlen(buf) );
+        return( len_orig - len ); /* return length of appended string */
 }
 
 static int format_seg( x86_op_t *op, char *buf, int len,
