diff options
author | Martin Liska <mliska@suse.cz> | 2017-04-13 13:51:28 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2017-04-13 11:51:28 +0000 |
commit | 0040ecb07f44769025a4d8e4952e8dd7b6d5149e (patch) | |
tree | fe6e31ea3731424b2034de5ecca201c14bee2789 /gcc/gcov-io.c | |
parent | 43a3aa03aca20c7d641cf76354c3572f2a7e5864 (diff) | |
download | gcc-0040ecb07f44769025a4d8e4952e8dd7b6d5149e.zip gcc-0040ecb07f44769025a4d8e4952e8dd7b6d5149e.tar.gz gcc-0040ecb07f44769025a4d8e4952e8dd7b6d5149e.tar.bz2 |
Do not call memcpy with a NULL argument (PR gcov-profile/80413).
2017-04-13 Martin Liska <mliska@suse.cz>
PR gcov-profile/80413
* gcov-io.c (gcov_write_string): Copy to buffer just when
allocated size is greater than zero.
From-SVN: r246903
Diffstat (limited to 'gcc/gcov-io.c')
-rw-r--r-- | gcc/gcov-io.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c index 3b6b022..64dedd5 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; /* place nul terminators. */ + memcpy (&buffer[1], string, length); + } } #endif |