]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: test-array - fix off-by-one in test_reverse
authorPhil Carmody <phil@dovecot.fi>
Tue, 25 Nov 2014 01:45:35 +0000 (03:45 +0200)
committerPhil Carmody <phil@dovecot.fi>
Tue, 25 Nov 2014 01:45:35 +0000 (03:45 +0200)
i is not used as an index, but as a count. Therefore, it can attain the
array size in the loop without causing any buffer overflows.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
src/lib/test-array.c

index 2c8a7a99974e13313415f80cd7468c908606c8cb..fb052795d88382f81f55adc7aafe951ed25f2eca 100644 (file)
@@ -41,7 +41,7 @@ static void test_array_reverse(void)
 
        test_begin("array reverse");
        t_array_init(&intarr, 5);
-       for (i = 0; i < N_ELEMENTS(input); i++) {
+       for (i = 0; i <= N_ELEMENTS(input); i++) {
                array_clear(&intarr);
                array_append(&intarr, input, i);
                array_reverse(&intarr);