]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86/disasm: avoid potentially leaking annotation buffers
authorJan Beulich <jbeulich@suse.com>
Fri, 22 May 2026 06:48:03 +0000 (08:48 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 22 May 2026 06:48:03 +0000 (08:48 +0200)
Address the FIXME there by moving the free() invocation out of the if().

opcodes/i386-dis.c

index fede65a0aa7f2422d184ef21691aff6c0c5a035c..ad0593cedd7393303d3e5dea8f2c2ad2163a8380 100644 (file)
@@ -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.  */