From: K.Kosako Date: Fri, 20 Sep 2019 05:56:07 +0000 (+0900) Subject: fix loose code in encode-harness.c X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3fe9880738210ce961ca66e4b22d33813def4227;p=onig fix loose code in encode-harness.c --- diff --git a/harnesses/encode-harness.c b/harnesses/encode-harness.c index 8a2dc7e..ade3c40 100644 --- a/harnesses/encode-harness.c +++ b/harnesses/encode-harness.c @@ -196,8 +196,7 @@ int LLVMFuzzerTestOneInput(const uint8_t * Data, size_t Size) #endif // copy first PATTERN_SIZE bytes off to be the pattern - unsigned char *pattern = (unsigned char *)malloc(MAX_PATTERN_SIZE + 4); - memset(pattern, 0, pattern_size + 4); + unsigned char *pattern = (unsigned char *)malloc(pattern_size != 0 ? pattern_size : 1); memcpy(pattern, data, pattern_size); pattern_end = pattern + pattern_size; data += pattern_size; @@ -207,8 +206,7 @@ int LLVMFuzzerTestOneInput(const uint8_t * Data, size_t Size) if (remaining_size % 2 == 1) remaining_size--; #endif - unsigned char *str = (unsigned char*)malloc(MAX_DATA_SIZE + 4); - memset(str, 0, remaining_size + 4); + unsigned char *str = (unsigned char*)malloc(remaining_size != 0 ? remaining_size : 1); memcpy(str, data, remaining_size); str_null_end = str + remaining_size;