On 3/5/26 8:15 AM, Peter Maydell wrote:
In patch_hwaddr() we allocate a GByteArray for the data we read back
from the guest; however we forget to free it, and the leak sanitizer
complains:

Direct leak of 40 byte(s) in 1 object(s) allocated from:
     #0 0x56c00ad48293 in malloc 
(/home/pm215/qemu/build/x86-tgt-san/qemu-system-x86_64+0x1a9f293) (BuildId: 
62e2a7dbe5ff146b2fa14d26e24e443f1967edd9)
     #1 0x7b3e4cc91ac9 in g_malloc 
(/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62ac9) (BuildId: 
116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
     #2 0x7b3e4cc54c12 in g_array_sized_new 
(/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x25c12) (BuildId: 
116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
     #3 0x7b3e44b06b49 in patch_hwaddr 
/home/pm215/qemu/build/x86-tgt-san/../../tests/tcg/plugins/patch.c:68:29

Indirect leak of 16 byte(s) in 1 object(s) allocated from:
     #0 0x56c00ad486b0 in realloc 
(/home/pm215/qemu/build/x86-tgt-san/qemu-system-x86_64+0x1a9f6b0) (BuildId: 
62e2a7dbe5ff146b2fa14d26e24e443f1967edd9)
     #1 0x7b3e4cc92819 in g_realloc 
(/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x63819) (BuildId: 
116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
     #2 0x7b3e4cc54b36  (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x25b36) 
(BuildId: 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
     #3 0x7b3e4cc55276 in g_array_set_size 
(/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x26276) (BuildId: 
116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
     #4 0x7b3e4cc55574 in g_byte_array_set_size 
(/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x26574) (BuildId: 
116e142b9b52c8a4dfd403e759e71ab8f95d8bb3)
     #5 0x56c00be2ccc1 in qemu_plugin_read_memory_hwaddr 
/home/pm215/qemu/build/x86-tgt-san/../../plugins/api.c:524:5

Mark the variable as g_autoptr(), as we already do in the equivalent
code in patch_vaddr().

Signed-off-by: Peter Maydell <[email protected]>
---
  tests/tcg/plugins/patch.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)


Reviewed-by: Pierrick Bouvier <[email protected]>

Reply via email to