From: Jan Beulich Date: Fri, 22 May 2026 06:48:03 +0000 (+0200) Subject: x86/disasm: avoid potentially leaking annotation buffers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=037292b02f4c48e80d1ab002cc589fe6c76e96ea;p=thirdparty%2Fbinutils-gdb.git x86/disasm: avoid potentially leaking annotation buffers Address the FIXME there by moving the free() invocation out of the if(). --- diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index fede65a0aa7..ad0593cedd7 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -11697,14 +11697,13 @@ oappend_immediate (instr_info *ins, bfd_vma imm) char * annotation = NULL; - /* FIXME: Potential memory leak: strictly speaking asprintf() - can return 0 whilst also having allocated some memory. */ if (asprintf (& annotation, " [%s]", sym->name) > 0) { /* Display the symbol associated with address 'imm'. */ cappend_with_style (ins, annotation, dis_style_symbol); - free (annotation); } + + free (annotation); } /* Put DISP in BUF as signed hex number. */