diff options
author | Jim Meyering <meyering@redhat.com> | 2012-04-13 09:46:24 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-04-13 11:17:04 +0200 |
commit | 6e6c1fb5e8c7fc7fe260e809e3bcdc0927d519cf (patch) | |
tree | 2b63127d0d30f01a647ca3ad4dea6a5133197896 | |
parent | 40679f5dbbb710bc3d09e0f410379fae20ba65e7 (diff) | |
download | grep-6e6c1fb5e8c7fc7fe260e809e3bcdc0927d519cf.tar.gz |
maint: dfa: avoid unnecessary uses of strcpy/strncpy
* src/dfa.c (icatalloc): Use memcpy, not strcpy, given the length.
(dfamust): Combine MALLOC+strcpy into cleaner xmemdup.
(parse_bracket_exp): Likewise, but replace a use of strncpy.
-rw-r--r-- | src/dfa.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -1024,9 +1024,7 @@ parse_bracket_exp (void) else if (MBS_SUPPORT && (c1 == '=' || c1 == '.')) { - char *elem; - MALLOC (elem, len + 1); - strncpy (elem, str, len + 1); + char *elem = xmemdup (str, len + 1); if (c1 == '=') /* build equivalent class. */ @@ -3667,7 +3665,7 @@ icatalloc (char *old, char const *new) if (newsize == 0) return old; result = xrealloc (old, oldsize + newsize + 1); - strcpy (result + oldsize, new); + memcpy (result + oldsize, new, newsize + 1); return result; } @@ -4060,8 +4058,7 @@ done: { MALLOC (dm, 1); dm->exact = exact; - MALLOC (dm->must, strlen (result) + 1); - strcpy (dm->must, result); + dm->must = xmemdup (result, strlen (result) + 1); dm->next = d->musts; d->musts = dm; } |