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')
|
cc = meson.get_compiler('c')
|
||||||
|
|
||||||
|
add_project_arguments(['-fsanitize=address', '-fno-omit-frame-pointer', '-ggdb', '-O0'], language : 'c')
|
||||||
|
|
||||||
# commandline options
|
# commandline options
|
||||||
PREFIX = get_option('prefix')
|
PREFIX = get_option('prefix')
|
||||||
DATAROOTDIR = join_paths(PREFIX, get_option('datarootdir'))
|
DATAROOTDIR = join_paths(PREFIX, get_option('datarootdir'))
|
||||||
|
@ -407,8 +409,8 @@ executable(
|
||||||
include_directories : includes,
|
include_directories : includes,
|
||||||
link_with : [libcommon],
|
link_with : [libcommon],
|
||||||
dependencies : [],
|
dependencies : [],
|
||||||
c_args : ['-fsanitize=fuzzer,address', '-ggdb'],
|
c_args : ['-fsanitize=fuzzer,address', '-ggdb', '-O0', '-fno-omit-frame-pointer'],
|
||||||
link_args : ['-fsanitize=fuzzer,address', '-ggdb'],
|
link_args : ['-fsanitize=fuzzer,address', '-ggdb', '-O0', '-fno-omit-frame-pointer'],
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach wrapper : script_wrappers
|
foreach wrapper : script_wrappers
|
||||||
|
|
|
@ -19,9 +19,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||||
cstring[Size] = 0;
|
cstring[Size] = 0;
|
||||||
|
|
||||||
char** ptr = wordsplit(cstring);
|
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);
|
free(cstring);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue