]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fts: Minor fix to randomness test in test-fts-tokenizer
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 25 Apr 2018 12:20:58 +0000 (15:20 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 27 Apr 2018 11:14:55 +0000 (14:14 +0300)
If the random input was entirely valid UTF-8, the input was truncated to
empty.

src/lib-fts/test-fts-tokenizer.c

index dcfb559a705cd0d0e84d4432eaf13c86bffb230f..9208189ba54d553c70efcc579c844aa0f01d95a2 100644 (file)
@@ -490,7 +490,8 @@ static void test_fts_tokenizer_random(void)
                for (unsigned int j = 0; j < sizeof(addr); j++)
                        addr[j] = test_chars[rand() % N_ELEMENTS(test_chars)];
                str_truncate(str, 0);
-               (void)uni_utf8_get_valid_data(addr, sizeof(addr), str);
+               if (uni_utf8_get_valid_data(addr, sizeof(addr), str))
+                       str_append_data(str, addr, sizeof(addr));
                while (fts_tokenizer_next(tok, str_data(str), str_len(str),
                                          &token, &error) > 0) ;
                while (fts_tokenizer_final(tok, &token, &error) > 0) ;