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

Unified Diff: media/filters/vpx_video_decoder_fuzzertest.cc

Issue 2453013005: Fix VpxVideoDecoder fuzzer: check initialize and wait for decode. (Closed)
Patch Set: Created 4 years, 2 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: media/filters/vpx_video_decoder_fuzzertest.cc
diff --git a/media/filters/vpx_video_decoder_fuzzertest.cc b/media/filters/vpx_video_decoder_fuzzertest.cc
index b780c66a47cdff617cf2940a34d9502c32da2c9f..f2d1e79a1b9783c141c38af5d36d03c6e9e56970 100644
--- a/media/filters/vpx_video_decoder_fuzzertest.cc
+++ b/media/filters/vpx_video_decoder_fuzzertest.cc
@@ -31,8 +31,17 @@ struct Env {
};
Env* env = new Env();
-void OnDecodeComplete(DecodeStatus status) {}
-void OnInitDone(bool success) {}
+void OnDecodeComplete(const base::Closure& quit_closure, DecodeStatus status) {
+ quit_closure.Run();
+}
+
+void OnInitDone(const base::Closure& quit_closure,
+ bool* success_dest,
+ bool success) {
+ *success_dest = success;
+ quit_closure.Run();
+}
+
void OnOutputComplete(const scoped_refptr<VideoFrame>& frame) {}
// Entry point for LibFuzzer.
@@ -60,15 +69,26 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
EmptyExtraData(), Unencrypted());
VpxVideoDecoder decoder;
- base::RunLoop run_loop;
- decoder.Initialize(config, true /* low_delay */, nullptr /* cdm_context */,
- base::Bind(&OnInitDone), base::Bind(&OnOutputComplete));
- run_loop.RunUntilIdle();
+ {
+ base::RunLoop run_loop;
+ bool success = false;
+ decoder.Initialize(
+ config, true /* low_delay */, nullptr /* cdm_context */,
+ base::Bind(&OnInitDone, run_loop.QuitClosure(), &success),
+ base::Bind(&OnOutputComplete));
+ run_loop.Run();
+ if (!success)
+ return 0;
+ }
- auto buffer = DecoderBuffer::CopyFrom(data, size);
- decoder.Decode(buffer, base::Bind(&OnDecodeComplete));
- run_loop.RunUntilIdle();
+ {
+ base::RunLoop run_loop;
+ auto buffer = DecoderBuffer::CopyFrom(data, size);
+ decoder.Decode(buffer,
+ base::Bind(&OnDecodeComplete, run_loop.QuitClosure()));
+ run_loop.Run();
+ }
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