Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1297)

Unified Diff: testing/libfuzzer/fuzzers/zlib_uncompress_fuzzer.cc

Issue 1635703002: Fix zlib_uncompress_fuzzer failure on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/libfuzzer/fuzzers/zlib_uncompress_fuzzer.cc
diff --git a/testing/libfuzzer/fuzzers/zlib_uncompress_fuzzer.cc b/testing/libfuzzer/fuzzers/zlib_uncompress_fuzzer.cc
index 952fe24771bb35c31e4bfbb1041bccfc4a0207e8..ccf3571f0c8bd53ab6d65127c8fb911835106898 100644
--- a/testing/libfuzzer/fuzzers/zlib_uncompress_fuzzer.cc
+++ b/testing/libfuzzer/fuzzers/zlib_uncompress_fuzzer.cc
@@ -3,16 +3,22 @@
// found in the LICENSE file.
#include <stdint.h>
+#include <string.h>
#include "third_party/zlib/zlib.h"
// Entry point for LibFuzzer.
extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size) {
- uint8_t buffer[1024 * 1024] = { 0 };
- size_t buffer_length = sizeof(buffer);
- if (Z_OK != uncompress(buffer, &buffer_length, data, size)) {
- return 0;
- }
+ const int NUM_ITEMS = 1024 * 1024;
+ const int BUF_SIZE = NUM_ITEMS * sizeof(uint8_t);
+ uint8_t *buffer = new uint8_t[NUM_ITEMS];
+ uLongf buffer_length = (uLongf)BUF_SIZE;
+ memset(buffer, 0, BUF_SIZE);
- return 0;
+ if (Z_OK != uncompress(buffer, &buffer_length, data, size)) {
+ delete[] buffer;
+ return 0;
+ }
+ delete[] buffer;
+ return 0;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698