[compiler-rt] r354918 - [libFuzzer] fix missing close on opened file

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 26 11:33:00 PST 2019


Author: vitalybuka
Date: Tue Feb 26 11:33:00 2019
New Revision: 354918

URL: http://llvm.org/viewvc/llvm-project?rev=354918&view=rev
Log:
[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

Modified:
    compiler-rt/trunk/lib/fuzzer/standalone/StandaloneFuzzTargetMain.c

Modified: compiler-rt/trunk/lib/fuzzer/standalone/StandaloneFuzzTargetMain.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/standalone/StandaloneFuzzTargetMain.c?rev=354918&r1=354917&r2=354918&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/standalone/StandaloneFuzzTargetMain.c (original)
+++ compiler-rt/trunk/lib/fuzzer/standalone/StandaloneFuzzTargetMain.c Tue Feb 26 11:33:00 2019
@@ -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);




More information about the llvm-commits mailing list