diff --git a/meson.build b/meson.build index 38b51661..8c71a63f 100644 --- a/meson.build +++ b/meson.build @@ -14,6 +14,8 @@ libalpm_version = '13.0.1' cc = meson.get_compiler('c') +add_project_arguments(['-fsanitize=address', '-fno-omit-frame-pointer', '-ggdb', '-O0'], language : 'c') + # commandline options PREFIX = get_option('prefix') DATAROOTDIR = join_paths(PREFIX, get_option('datarootdir')) @@ -407,8 +409,8 @@ executable( include_directories : includes, link_with : [libcommon], dependencies : [], - c_args : ['-fsanitize=fuzzer,address', '-ggdb'], - link_args : ['-fsanitize=fuzzer,address', '-ggdb'], + c_args : ['-fsanitize=fuzzer,address', '-ggdb', '-O0', '-fno-omit-frame-pointer'], + link_args : ['-fsanitize=fuzzer,address', '-ggdb', '-O0', '-fno-omit-frame-pointer'], ) foreach wrapper : script_wrappers diff --git a/src/fuzzing/fuzz_util_string_length.c b/src/fuzzing/fuzz_util_string_length.c index f7761434..a6b04fb2 100644 --- a/src/fuzzing/fuzz_util_string_length.c +++ b/src/fuzzing/fuzz_util_string_length.c @@ -23,4 +23,4 @@ static int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { free(cstring); return 0; -} \ No newline at end of file +} diff --git a/src/fuzzing/fuzz_wordsplit.c b/src/fuzzing/fuzz_wordsplit.c index 06c0fc48..2e4b41ce 100644 --- a/src/fuzzing/fuzz_wordsplit.c +++ b/src/fuzzing/fuzz_wordsplit.c @@ -19,9 +19,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { cstring[Size] = 0; char** ptr = wordsplit(cstring); - if (ptr) - free(ptr); + // Free the memory allocated by wordsplit + if (ptr) { + int i = 0; + char* p = ptr[i++]; + while (p) { + free(p); + p = ptr[i++]; + } + free(ptr); + } + + // Free the allocated cstring free(cstring); return 0;