Author: se Date: Sat Jan 26 22:24:15 2019 New Revision: 343482 URL: https://svnweb.freebsd.org/changeset/base/343482
Log: Slightly improve previous commit that silenced a Clang Scan warning. The strdup() call does not take advantage of the known length of the source string. Replace by malloc() and memcpy() utilizimng the pre- calculated string length. Submitted by: cperciva Reported by: rgrimes MFC after: 2 weeks Modified: head/lib/libfigpar/string_m.c Modified: head/lib/libfigpar/string_m.c ============================================================================== --- head/lib/libfigpar/string_m.c Sat Jan 26 21:35:51 2019 (r343481) +++ head/lib/libfigpar/string_m.c Sat Jan 26 22:24:15 2019 (r343482) @@ -119,9 +119,10 @@ replaceall(char *source, const char *find, const char /* If replace is longer than find, we'll need to create a temp copy */ if (rlen > flen) { - temp = strdup(source); + temp = malloc(slen + 1); if (temp == NULL) /* could not allocate memory */ return (-1); + memcpy(temp, source, slen + 1); } else temp = source; _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"