OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv); | 10 extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv); |
(...skipping 24 matching lines...) Expand all Loading... |
35 uint8_t* data = reinterpret_cast<uint8_t*>(malloc(size)); | 35 uint8_t* data = reinterpret_cast<uint8_t*>(malloc(size)); |
36 if (!data) { | 36 if (!data) { |
37 fclose(input); | 37 fclose(input); |
38 fprintf(stderr, "Failed to allocate %ld bytes\n", size); | 38 fprintf(stderr, "Failed to allocate %ld bytes\n", size); |
39 return 1; | 39 return 1; |
40 } | 40 } |
41 | 41 |
42 size_t bytes_read = fread(data, 1, size, input); | 42 size_t bytes_read = fread(data, 1, size, input); |
43 fclose(input); | 43 fclose(input); |
44 | 44 |
45 if (bytes_read != size) { | 45 if (bytes_read != static_cast<size_t>(size)) { |
46 free(data); | 46 free(data); |
47 fprintf(stderr, "Failed to read %s\n", argv[1]); | 47 fprintf(stderr, "Failed to read %s\n", argv[1]); |
48 return 1; | 48 return 1; |
49 } | 49 } |
50 | 50 |
51 int result = LLVMFuzzerTestOneInput(data, size); | 51 int result = LLVMFuzzerTestOneInput(data, size); |
52 | 52 |
53 free(data); | 53 free(data); |
54 | 54 |
55 return result; | 55 return result; |
56 } | 56 } |
OLD | NEW |