[libFuzzer] fix missing close on opened file

Summary:
When running the standalone main on a large corpus, I eventually get a
EMFILE error ("Too many open files").

Patch by Paul Chaignon

Reviewers: kcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: lebedev.ri, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D58622

llvm-svn: 354918
This commit is contained in:
Vitaly Buka 2019-02-26 19:33:00 +00:00
parent 01706bda5b
commit 9b6135bf2a
1 changed files with 1 additions and 0 deletions

View File

@ -32,6 +32,7 @@ int main(int argc, char **argv) {
fseek(f, 0, SEEK_SET);
unsigned char *buf = (unsigned char*)malloc(len);
size_t n_read = fread(buf, 1, len, f);
fclose(f);
assert(n_read == len);
LLVMFuzzerTestOneInput(buf, len);
free(buf);