Hello. As the function is called with argument equal to zero, the memcpy should be done just in case alloc is greater than zero.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. And gcov.exp works on x86_64-linux-gnu. Ready to be installed? Martin
>From 82f609465a9702a0c4ce0c4dbe9c3bd744a3ea34 Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Thu, 13 Apr 2017 10:35:29 +0200 Subject: [PATCH] Do not call memcpy with a NULL argument (PR gcov-profile/80413). gcc/ChangeLog: 2017-04-13 Martin Liska <mli...@suse.cz> PR gcov-profile/80413 * gcov-io.c (gcov_write_string): Copy to buffer just when allocated size is greater than zero. --- gcc/gcov-io.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c index 3b6b022d143..18e0f7f4b1b 100644 --- a/gcc/gcov-io.c +++ b/gcc/gcov-io.c @@ -347,8 +347,12 @@ gcov_write_string (const char *string) buffer = gcov_write_words (1 + alloc); buffer[0] = alloc; - buffer[alloc] = 0; - memcpy (&buffer[1], string, length); + + if (alloc > 0) + { + buffer[alloc] = 0; + memcpy (&buffer[1], string, length); + } } #endif -- 2.12.2