summaryrefslogtreecommitdiff
path: root/libgcompat/string.c
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-05-08 20:11:22 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-05-08 20:11:22 -0500
commit8d59ff51c5d05ece395da3df13dd06821f9154bf (patch)
tree36f4c1b3b8ce72c7be4c1b7dc2aa075d9c28176f /libgcompat/string.c
parente3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b (diff)
downloadgcompat-8d59ff51c5d05ece395da3df13dd06821f9154bf.tar.gz
gcompat-8d59ff51c5d05ece395da3df13dd06821f9154bf.tar.bz2
gcompat-8d59ff51c5d05ece395da3df13dd06821f9154bf.tar.xz
gcompat-8d59ff51c5d05ece395da3df13dd06821f9154bf.zip
Don't use variables until ensuring they're non-NULL
Diffstat (limited to 'libgcompat/string.c')
-rw-r--r--libgcompat/string.c3
1 files changed, 2 insertions, 1 deletions
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);