From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C955145C304 for ; Thu, 3 Dec 2020 17:39:04 +0300 (MSK) From: Kirill Yukhin Date: Thu, 3 Dec 2020 17:38:50 +0300 Message-Id: <86d41c348ae271f5a8a8dec6fdd4ccc045a0408d.1607006062.git.kyukhin@tarantool.org> Subject: [Tarantool-patches] [PATCH] test: fix local array access in heap_iterator unit test List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: alyapunov@tarantool.org, avtikhon@tarantool.org Cc: tarantool-patches@dev.tarantool.org Index variable run from 1 to 5 and was used to index array of size 4. Use iv - 1 instead. Discovered by Coverity. --- Issue: N/A Branch: https://github.com/tarantool/tarantool/tree/kyukhin/fix-heap_iterator CI: https://gitlab.com/tarantool/tarantool/-/pipelines/224811793 test/unit/heap_iterator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/heap_iterator.c b/test/unit/heap_iterator.c index 4fde39d..3fcefff 100644 --- a/test/unit/heap_iterator.c +++ b/test/unit/heap_iterator.c @@ -111,15 +111,15 @@ test_iterator_small() if (val < 1 || val > 5) fail("from iterator returned incorrect value", "val < 1 || val > 5"); - if (used_key[val]) + if (used_key[val - 1]) fail("from iterator some value returned twice", "used[val]"); - used_key[val] = 1; + used_key[val - 1] = 1; } bool f = true; for (uint32_t i = 1; i < 5; ++i) - f = used_key[i] && f; + f = used_key[i - 1] && f; if (!f) fail("some node was skipped", "!f"); -- 2.11.0