unicorn/qemu/include
Eric Blake c14d8226ab
qapi: Fix memleak in string visitors on int lists
Commit 7f8f9ef1 introduced the ability to store a list of
integers as a sorted list of ranges, but when merging ranges,
it leaks one or more ranges. It was also using range_get_last()
incorrectly within range_compare() (a range is a start/end pair,
but range_get_last() is for start/len pairs), and will also
mishandle a range ending in UINT64_MAX (remember, we document
that no range covers 2**64 bytes, but that ranges that end on
UINT64_MAX have end < begin).

The whole merge algorithm was rather complex, and included
unnecessary passes over data within glib functions, and enough
indirection to make it hard to easily plug the data leaks.
Since we are already hard-coding things to a list of ranges,
just rewrite the thing to open-code the traversal and
comparisons, by making the range_compare() helper function give
us an answer that is easier to use, at which point we avoid the
need to pass any callbacks to g_list_*(). Then by reusing
range_extend() instead of duplicating effort with range_merge(),
we cover the corner cases correctly.

Drop the now-unused range_merge() and ranges_can_merge().

Doing this lets test-string-{input,output}-visitor pass under
valgrind without leaks.

Backports commit db486cc334aafd3dbdaf107388e37fc3d6d3e171 from qemu
2018-02-25 00:20:34 -05:00
..
crypto Drop unused crypto source files 2018-02-17 15:23:57 -05:00
exec memory: Add reporting of supported page sizes 2018-02-24 19:23:28 -05:00
fpu softfloat: Implement run-time-configurable meaning of signaling NaN bit 2018-02-24 20:27:12 -05:00
hw hw: clean up hw/hw.h includes 2018-02-24 02:46:41 -05:00
qapi qapi: Change visit_type_FOO() to no longer return partial objects 2018-02-23 19:53:17 -05:00
qemu qapi: Simplify use of range.h 2018-02-25 00:02:42 -05:00
qom qom: API to get instance_size of a type 2018-02-24 19:00:16 -05:00
sysemu accel: make configure_accelerator return void 2018-02-24 00:31:28 -05:00
config.h import 2015-08-21 15:04:50 +08:00
elf.h fix merge conflicts 2017-03-10 21:04:33 +08:00
glib_compat.h qapi: Fix memleak in string visitors on int lists 2018-02-25 00:20:34 -05:00
qemu-common.h qemu-common.h: Drop WORDS_ALIGNED define 2018-02-24 17:01:55 -05:00