From 0ba7eeef2ea36b4e4ed5d79e85f566dd459ad9b1 Mon Sep 17 00:00:00 2001 From: Google AutoFuzz Team Date: Mon, 18 Jan 2021 22:17:06 +0100 Subject: [PATCH] Add a check to prevent cairo from immediately crashing (#4992) --- projects/cairo/targets/pdf_surface_fuzzer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/cairo/targets/pdf_surface_fuzzer.c b/projects/cairo/targets/pdf_surface_fuzzer.c index 7869f6371..7967d1d32 100644 --- a/projects/cairo/targets/pdf_surface_fuzzer.c +++ b/projects/cairo/targets/pdf_surface_fuzzer.c @@ -26,6 +26,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { cairo_surface_t *surface; cairo_status_t status; + if (size == 0) { + return 0; + } + char *tmpfile = fuzzer_get_tmpfile(data, size); surface = cairo_pdf_surface_create(tmpfile, width_in_points, height_in_points); status = cairo_surface_status(surface);