Fix memory leak in fuzz_wordsplit
This commit is contained in:
parent
5467b4180b
commit
ee352110f5
3 changed files with 17 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -23,4 +23,4 @@ static int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
|||
free(cstring);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue