diff options
author | Li Zhijian <lizhijian@fujitsu.com> | 2025-06-13 16:51:10 +0800 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2025-07-14 09:16:40 -0400 |
commit | d7fb5693d9ffbeb9b49c981e1f9774392f1d41e5 (patch) | |
tree | 0276d9d1e8631adcfd4a4eecb4ac24264f0d37ae /rust/qemu-api | |
parent | 85240876b2f6f9edd72a6f324cac0ee9ee28ab0a (diff) | |
download | qemu-d7fb5693d9ffbeb9b49c981e1f9774392f1d41e5.zip qemu-d7fb5693d9ffbeb9b49c981e1f9774392f1d41e5.tar.gz qemu-d7fb5693d9ffbeb9b49c981e1f9774392f1d41e5.tar.bz2 |
hw/acpi: Fix GPtrArray memory leak in crs_range_merge
This leak was detected by the valgrind.
The crs_range_merge() function unconditionally allocated a GPtrArray
'even when range->len was zero, causing an early return without freeing
the allocated array. This resulted in a memory leak when an empty range
was processed.
Instead of moving the allocation after the check (as previously attempted),
use g_autoptr for automatic cleanup. This ensures the array is freed even
on early returns, and also removes the need for the explicit free at the
end of the function.
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Message-Id: <20250613085110.111204-1-lizhijian@fujitsu.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'rust/qemu-api')
0 files changed, 0 insertions, 0 deletions