summary refs log tree commit diff stats
path: root/tests/test-string-input-visitor.c
diff options
context:
space:
mode:
authorAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>2019-07-30 19:01:37 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2019-08-20 17:26:19 +0200
commitf673174e3f62096f45b874fbe1cd469127d9c21c (patch)
tree08a89b222bc327fea347e7da25157394e4c65d1c /tests/test-string-input-visitor.c
parentef0aa6af47da16f5367f545deb599a14ea408bee (diff)
downloadfocaccia-qemu-f673174e3f62096f45b874fbe1cd469127d9c21c.tar.gz
focaccia-qemu-f673174e3f62096f45b874fbe1cd469127d9c21c.zip
tests: Fix uninitialized byte in test_visitor_in_fuzz
One byte in the local buffer stays uninitialized, at least with the
first iteration, because of the double decrement in the
test_visitor_in_fuzz(). This is what Valgrind does not like and not
critical for the test itself. So, reduce the number of the memory
issues reports.

Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Message-Id: <1564502498-805893-3-git-send-email-andrey.shinkevich@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/test-string-input-visitor.c')
-rw-r--r--tests/test-string-input-visitor.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c
index 34b54dfc89..5418e085a4 100644
--- a/tests/test-string-input-visitor.c
+++ b/tests/test-string-input-visitor.c
@@ -444,16 +444,14 @@ static void test_visitor_in_fuzz(TestInputVisitorData *data,
     char buf[10000];
 
     for (i = 0; i < 100; i++) {
-        unsigned int j;
+        unsigned int j, k;
 
         j = g_test_rand_int_range(0, sizeof(buf) - 1);
 
         buf[j] = '\0';
 
-        if (j != 0) {
-            for (j--; j != 0; j--) {
-                buf[j - 1] = (char)g_test_rand_int_range(0, 256);
-            }
+        for (k = 0; k != j; k++) {
+            buf[k] = (char)g_test_rand_int_range(0, 256);
         }
 
         v = visitor_input_test_init(data, buf);