diff options
-rw-r--r-- | libgcompat/string.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libgcompat/string.c b/libgcompat/string.c index 1b3673b..9852bea 100644 --- a/libgcompat/string.c +++ b/libgcompat/string.c @@ -145,11 +145,13 @@ char *__stpncpy_chk(char *dest, const char *src, size_t n, size_t destlen) */ char *__strcat_chk(char *dest, const char *src, size_t destlen) { - size_t n = strlen(src) + 1; - size_t total = strnlen(dest, destlen) + n; + size_t n; + size_t total; assert(dest != NULL); assert(src != NULL); + n = strlen(src) + 1; + total = strnlen(dest, destlen) + n; assert(destlen >= total); if (dest < src) { assert(dest + total <= src); @@ -215,10 +217,11 @@ char *__strdup(const char *string) */ char *__strncat_chk(char *dest, const char *src, size_t n, size_t destlen) { - size_t total = strnlen(dest, destlen) + n + 1; + size_t total; assert(dest != NULL); assert(src != NULL); + total = strnlen(dest, destlen) + n + 1; assert(destlen >= total); if (dest < src) { assert(dest + total <= src); |