diff options
author | Stefan Eßer <se@FreeBSD.org> | 2019-01-26 21:30:26 +0000 |
---|---|---|
committer | Stefan Eßer <se@FreeBSD.org> | 2019-01-26 21:30:26 +0000 |
commit | 4268f3b3e0d87bc090b7fe0f95fb52a2e904db25 (patch) | |
tree | f8272c87cf78db708796539e2c315e83565b1f39 /lib/libfigpar | |
parent | 71bc4af6edda147f6272a5c525c213d36ce7d9ec (diff) | |
download | src-test-4268f3b3e0d87bc090b7fe0f95fb52a2e904db25.tar.gz src-test-4268f3b3e0d87bc090b7fe0f95fb52a2e904db25.zip |
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
Notes
Notes:
svn path=/head/; revision=343480
Diffstat (limited to 'lib/libfigpar')
-rw-r--r-- | lib/libfigpar/string_m.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libfigpar/string_m.c b/lib/libfigpar/string_m.c index d358e90488d7d..c991aebb4a575 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; |