Skip to content

Commit 8a7db0f

Browse files
authored
actually fuzz utf8proc_normalize_utf32 in the fuzz target (#365)
1 parent 79cdd5a commit 8a7db0f

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎test/fuzzer.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,34 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
4242
c_prev = c;
4343
}
4444

45-
utf8proc_int32_t *copy = size >= 4 ? NULL : malloc(size);
45+
utf8proc_int32_t *copy = size >= 4 ? malloc(size) : NULL;
4646

4747
if(copy)
4848
{
49-
size /= 4;
49+
size /= 4; /* number of utf8proc_int32_t code points that fit in copy */
5050

5151
options = UTF8PROC_STRIPCC | UTF8PROC_NLF2LS | UTF8PROC_NLF2PS;
52-
memcpy(copy, data, size);
52+
memcpy(copy, data, size * sizeof(utf8proc_int32_t));
5353
utf8proc_normalize_utf32(copy, size, options);
5454

5555
options = UTF8PROC_STRIPCC | UTF8PROC_NLF2LS;
56-
memcpy(copy, data, size);
56+
memcpy(copy, data, size * sizeof(utf8proc_int32_t));
5757
utf8proc_normalize_utf32(copy, size, options);
5858

5959
options = UTF8PROC_STRIPCC | UTF8PROC_NLF2PS;
60-
memcpy(copy, data, size);
60+
memcpy(copy, data, size * sizeof(utf8proc_int32_t));
6161
utf8proc_normalize_utf32(copy, size, options);
6262

6363
options = UTF8PROC_STRIPCC;
64-
memcpy(copy, data, size);
64+
memcpy(copy, data, size * sizeof(utf8proc_int32_t));
6565
utf8proc_normalize_utf32(copy, size, options);
6666

6767
options = UTF8PROC_LUMP;
68-
memcpy(copy, data, size);
68+
memcpy(copy, data, size * sizeof(utf8proc_int32_t));
6969
utf8proc_normalize_utf32(copy, size, options);
7070

7171
options = 0;
72-
memcpy(copy, data, size);
72+
memcpy(copy, data, size * sizeof(utf8proc_int32_t));
7373
utf8proc_normalize_utf32(copy, size, options);
7474

7575
free(copy);

0 commit comments

Comments
 (0)