Do not call strlen with NULL argument in libgcov.

2019-06-25  Martin Liska  <mliska@suse.cz>

	* libgcov-driver-system.c (replace_filename_variables): Do not
	call strlen with NULL argument.

From-SVN: r272650
This commit is contained in:
Martin Liska 2019-06-25 13:49:36 +02:00 committed by Martin Liska
parent b1e86e33a2
commit e5ce4cbc72
2 changed files with 8 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2019-06-25 Martin Liska <mliska@suse.cz>
* libgcov-driver-system.c (replace_filename_variables): Do not
call strlen with NULL argument.
2019-06-25 Andrew Stubbs <ams@codesourcery.com>
* config/gcn/t-amdgcn (LIB2ADD): Add unwind-gcn.c.

View File

@ -186,13 +186,14 @@ replace_filename_variables (char *filename)
/* Concat beginning of the path, replacement and
ending of the path. */
unsigned end = length - (p - filename);
unsigned repl_length = strlen (replacement);
unsigned repl_length = replacement != NULL ? strlen (replacement) : 0;
char *buffer = (char *)xmalloc (start + end + repl_length + 1);
char *buffer_ptr = buffer;
buffer_ptr = (char *)memcpy (buffer_ptr, filename, start);
buffer_ptr += start;
buffer_ptr = (char *)memcpy (buffer_ptr, replacement, repl_length);
if (replacement != NULL)
buffer_ptr = (char *)memcpy (buffer_ptr, replacement, repl_length);
buffer_ptr += repl_length;
buffer_ptr = (char *)memcpy (buffer_ptr, p, end);
buffer_ptr += end;