qemu-e2k/util
Eric Blake db486cc334 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.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1464712890-14262-4-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Comment hoisted out of loop]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-06-30 15:28:54 +02:00
..
acl.c
base64.c include/qemu/osdep.h: Don't include qapi/error.h 2016-03-22 22:20:15 +01:00
bitmap.c
bitops.c
buffer.c qemu-common: stop including qemu/host-utils.h from qemu-common.h 2016-05-19 16:42:28 +02:00
compatfd.c
coroutine-gthread.c all: Remove unnecessary glib.h includes 2016-06-07 18:19:24 +03:00
coroutine-sigaltstack.c Remove unneeded include statements for setjmp.h 2016-03-22 19:11:15 +01:00
coroutine-ucontext.c Remove unneeded include statements for setjmp.h 2016-03-22 19:11:15 +01:00
coroutine-win32.c
crc32c.c
cutils.c avx2 configure: Use primitives in test 2016-06-16 18:39:04 +02:00
envlist.c
error.c migration: add reporting of errors for outgoing migration 2016-05-26 11:31:30 +05:30
event_notifier-posix.c event-notifier: Add "is_external" parameter 2016-04-22 16:43:56 +02:00
event_notifier-win32.c event-notifier: Add "is_external" parameter 2016-04-22 16:43:56 +02:00
fifo8.c
getauxval.c
hbitmap.c hbitmap: add 'pos < size' asserts 2016-06-16 15:20:37 +02:00
hexdump.c util: Improved qemu_hexmap() to include an ascii dump of the buffer 2016-04-06 09:52:07 +08:00
host-utils.c
id.c util: move declarations out of qemu-common.h 2016-03-22 22:20:17 +01:00
iov.c util: move declarations out of qemu-common.h 2016-03-22 22:20:17 +01:00
log.c log: Fix qemu_set_log_filename() error handling 2016-06-20 16:39:08 +02:00
Makefile.objs range: Create range.c for code that should not be inline 2016-06-30 15:28:40 +02:00
memfd.c os-posix: include sys/mman.h 2016-06-16 18:39:03 +02:00
mmap-alloc.c os-posix: include sys/mman.h 2016-06-16 18:39:03 +02:00
module.c coccinelle: Remove unnecessary variables for function return value 2016-06-20 16:38:13 +02:00
notify.c
osdep.c os-posix: include sys/mman.h 2016-06-16 18:39:03 +02:00
oslib-posix.c os-posix: include sys/mman.h 2016-06-16 18:39:03 +02:00
oslib-win32.c all: Remove unnecessary glib.h includes 2016-06-07 18:19:24 +03:00
path.c util: move declarations out of qemu-common.h 2016-03-22 22:20:17 +01:00
qdist.c clean-includes: run it once more 2016-06-16 18:39:03 +02:00
qemu-config.c
qemu-coroutine-io.c osdep: remove use of socket_error() from all code 2016-03-10 17:19:34 +00:00
qemu-coroutine-lock.c
qemu-coroutine-sleep.c
qemu-coroutine.c
qemu-error.c
qemu-openpty.c
qemu-option.c QemuOpts: Fix qemu_opts_foreach() dangling location regression 2016-04-28 08:18:56 +02:00
qemu-progress.c
qemu-sockets.c * serial port fixes (Paolo) 2016-06-29 19:14:48 +01:00
qemu-thread-posix.c
qemu-thread-win32.c
qemu-timer-common.c
qht.c clean-includes: run it once more 2016-06-16 18:39:03 +02:00
range.c qapi: Fix memleak in string visitors on int lists 2016-06-30 15:28:54 +02:00
rcu.c
readline.c util: move declarations out of qemu-common.h 2016-03-22 22:20:17 +01:00
rfifolock.c rfifolock: no need to get thread identifier when nesting 2016-05-16 15:29:44 -07:00
throttle.c throttle: refuse iops-size without iops-total/read/write 2016-06-07 14:40:51 +01:00
timed-average.c Fix some typos found by codespell 2016-05-18 15:04:27 +03:00
trace-events trace: split out trace events for util/ directory 2016-06-20 17:22:14 +01:00
unicode.c util: move declarations out of qemu-common.h 2016-03-22 22:20:17 +01:00
uri.c all: Remove unnecessary glib.h includes 2016-06-07 18:19:24 +03:00