Commit 0040ecb0 by Martin Liska Committed by Martin Liska

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
parent 43a3aa03
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.
2017-04-13 Jakub Jelinek <jakub@redhat.com> 2017-04-13 Jakub Jelinek <jakub@redhat.com>
PR debug/80321 PR debug/80321
......
...@@ -347,8 +347,12 @@ gcov_write_string (const char *string) ...@@ -347,8 +347,12 @@ gcov_write_string (const char *string)
buffer = gcov_write_words (1 + alloc); buffer = gcov_write_words (1 + alloc);
buffer[0] = 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 #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment