]> git.proxmox.com Git - mirror_qemu.git/commit
tests/test-string-input-visitor: Handle errors provoked by fuzz test
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 5 Feb 2013 20:44:23 +0000 (20:44 +0000)
committerLuiz Capitulino <lcapitulino@redhat.com>
Thu, 7 Feb 2013 15:22:50 +0000 (13:22 -0200)
commit0184543814354d37eab75132712c3874d71dd776
treea39e4dca82647ff94662731d5a42703dde60b8fc
parentecd8d4715ea33aa2c146a5047bacb031e86af599
tests/test-string-input-visitor: Handle errors provoked by fuzz test

It's OK and expected for visitors to return errors when presented with
the fuzz test's random data. Since the fuzzer doesn't care about
errors, we pass in NULL rather than an Error**. This fixes a bug in
the fuzzer where it was passing the same Error** into each visitor,
with the effect that once one visitor returned an error, each later
visitor would notice that it had been passed in an Error** representing
an already set error, and do nothing.

For the case of visit_type_str() we also need to handle the case where
an error means that the visitor doesn't set our char*. We initialize
the pointer to NULL so we can safely g_free() it regardless of whether
the visitor allocated a string for us or not.

This fixes a problem where this test failed the MacOSX malloc()
consistency checks and might segfault on other platforms [due
to calling free() on an uninitialized pointer variable when
visit_type_str() failed.].

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
tests/test-string-input-visitor.c