From: Martin Liska Date: Tue, 25 Jun 2019 11:49:36 +0000 (+0200) Subject: Do not call strlen with NULL argument in libgcov. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e5ce4cbc72adbfc8284ed6998b7d36c9f50c1ef6;p=gcc.git Do not call strlen with NULL argument in libgcov. 2019-06-25 Martin Liska * libgcov-driver-system.c (replace_filename_variables): Do not call strlen with NULL argument. From-SVN: r272650 --- diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 4b9a47071d4..a5896155bb4 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,8 @@ +2019-06-25 Martin Liska + + * libgcov-driver-system.c (replace_filename_variables): Do not + call strlen with NULL argument. + 2019-06-25 Andrew Stubbs * config/gcn/t-amdgcn (LIB2ADD): Add unwind-gcn.c. diff --git a/libgcc/libgcov-driver-system.c b/libgcc/libgcov-driver-system.c index b5f3e89ebdc..39dc62749d5 100644 --- a/libgcc/libgcov-driver-system.c +++ b/libgcc/libgcov-driver-system.c @@ -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;