From 4268f3b3e0d87bc090b7fe0f95fb52a2e904db25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20E=C3=9Fer?= Date: Sat, 26 Jan 2019 21:30:26 +0000 Subject: [PATCH] Silence Clang Scan warning about potentially unsafe use of strcpy. While this is a false positive, the use of strdup() simplifies the code. MFC after: 2 weeks --- lib/libfigpar/string_m.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/libfigpar/string_m.c b/lib/libfigpar/string_m.c index d358e90488d..c991aebb4a5 100644 --- a/lib/libfigpar/string_m.c +++ b/lib/libfigpar/string_m.c @@ -119,10 +119,9 @@ replaceall(char *source, const char *find, const char *replace) /* If replace is longer than find, we'll need to create a temp copy */ if (rlen > flen) { - temp = malloc(slen + 1); - if (errno != 0) /* could not allocate memory */ + temp = strdup(source); + if (temp == NULL) /* could not allocate memory */ return (-1); - strcpy(temp, source); } else temp = source;