From 558f922788ccceaa80c31bf0e379be4c96598d13 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Tue, 3 Mar 2020 20:27:19 +0330 Subject: [PATCH] [fuzz] Avoid empty memcpy and ubsan complain by length checking before memcpy --- test/fuzzing/hb-shape-fuzzer.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/fuzzing/hb-shape-fuzzer.cc b/test/fuzzing/hb-shape-fuzzer.cc index c761b2a39..eb03132c3 100644 --- a/test/fuzzing/hb-shape-fuzzer.cc +++ b/test/fuzzing/hb-shape-fuzzer.cc @@ -41,7 +41,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) unsigned int len = sizeof (text32); if (size < len) len = size; - memcpy(text32, data + size - len, len); + if (len) + memcpy(text32, data + size - len, len); hb_buffer_t *buffer = hb_buffer_create (); hb_buffer_add_utf32 (buffer, text32, sizeof (text32) / sizeof (text32[0]), 0, -1);