From 8d59ff51c5d05ece395da3df13dd06821f9154bf Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Wed, 8 May 2019 20:11:22 -0500 Subject: Don't use variables until ensuring they're non-NULL --- libgcompat/string.c | 3 ++- libgcompat/wchar.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'libgcompat') diff --git a/libgcompat/string.c b/libgcompat/string.c index acc0566..f96e8d6 100644 --- a/libgcompat/string.c +++ b/libgcompat/string.c @@ -103,10 +103,11 @@ weak_alias(__rawmemchr, rawmemchr); */ char *__stpcpy_chk(char *dest, const char *src, size_t destlen) { - size_t n = strlen(src) + 1; + size_t n; assert(dest != NULL); assert(src != NULL); + n = strlen(src) + 1; assert(destlen >= n); if (dest < src) { assert(dest + n <= src); diff --git a/libgcompat/wchar.c b/libgcompat/wchar.c index 1a5a23c..4ed7a7b 100644 --- a/libgcompat/wchar.c +++ b/libgcompat/wchar.c @@ -46,10 +46,11 @@ int __vswprintf_chk(wchar_t *s, size_t n, int flag, size_t slen, */ wchar_t *__wcscpy_chk(wchar_t *dest, const wchar_t *src, size_t n) { - size_t srclen = wcslen(src) + 1; + size_t srclen; assert(dest != NULL); assert(src != NULL); + srclen = wcslen(src) + 1; assert(n >= srclen); if (dest < src) { assert(dest + n <= src); -- cgit v1.2.3-70-g09d2