[PATCH] D40921: [libFuzzer] standalone fuzzer: close file after reading

Jakub Zawadzki via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 13:52:41 PST 2017


jzawadzki created this revision.
Herald added subscribers: Sanitizers, llvm-commits.

Add missing fclose() after fread() to avoid resource leak.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D40921

Files:
  StandaloneFuzzTargetMain.c


Index: StandaloneFuzzTargetMain.c
===================================================================
--- StandaloneFuzzTargetMain.c
+++ StandaloneFuzzTargetMain.c
@@ -34,6 +34,7 @@
     unsigned char *buf = (unsigned char*)malloc(len);
     size_t n_read = fread(buf, 1, len, f);
     assert(n_read == len);
+    fclose(f);
     LLVMFuzzerTestOneInput(buf, len);
     free(buf);
     fprintf(stderr, "Done:    %s: (%zd bytes)\n", argv[i], n_read);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40921.125802.patch
Type: text/x-patch
Size: 449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171206/3e577631/attachment.bin>


More information about the llvm-commits mailing list