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

Unified Diff: media/filters/h264_parser_fuzzertest.cc

Issue 2268183009: H264SPS: Centralize computation of coded size and visible rect. (Closed)
Patch Set: Make sure fuzzing code actually runs. Created 4 years, 4 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 | « media/filters/h264_parser.cc ('k') | media/filters/h264_parser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/h264_parser_fuzzertest.cc
diff --git a/media/filters/h264_parser_fuzzertest.cc b/media/filters/h264_parser_fuzzertest.cc
index c0d852f8fb58bd0adf42bfd69f6ca30d3713946c..9cfb855b8dbf05a878fc8ab87a911b04a59a78aa 100644
--- a/media/filters/h264_parser_fuzzertest.cc
+++ b/media/filters/h264_parser_fuzzertest.cc
@@ -5,7 +5,12 @@
#include <stddef.h>
#include "base/numerics/safe_conversions.h"
+#include "base/optional.h"
#include "media/filters/h264_parser.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/size.h"
+
+static volatile size_t volatile_sink;
// Entry point for LibFuzzer.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
@@ -34,6 +39,17 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
case media::H264NALU::kSPS: {
int id;
res = parser.ParseSPS(&id);
+ if (res != media::H264Parser::kOk)
+ break;
+ const media::H264SPS* sps = parser.GetSPS(id);
+ if (!sps)
+ break;
+ // Also test the SPS helper methods. We make sure that the results are
+ // used so that the calls are not optimized away.
+ base::Optional<gfx::Size> coded_size = sps->GetCodedSize();
+ volatile_sink = coded_size.value_or(gfx::Size()).ToString().length();
+ base::Optional<gfx::Rect> visible_rect = sps->GetVisibleRect();
+ volatile_sink = visible_rect.value_or(gfx::Rect()).ToString().length();
break;
}
« no previous file with comments | « media/filters/h264_parser.cc ('k') | media/filters/h264_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698