From efb1f061f10c50410ede9401ccddaf93240f8335 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 8 Mar 2012 14:56:18 +0000 Subject: [PATCH] * path.cc (readlink): Avoid calling strlen() twice. --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/path.cc | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 698587559..9b3f8eb76 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2012-03-08 Václav Zeman + + * path.cc (readlink): Avoid calling strlen() twice. + 2012-03-07 Corinna Vinschen * Throughout, replace usage of w32api's min with MIN from sys/param.h. diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 17ae5e109..ea984c2e5 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2783,7 +2783,8 @@ readlink (const char *path, char *buf, size_t buflen) return -1; } - ssize_t len = MIN (buflen, strlen (pathbuf.get_win32 ())); + size_t pathbuf_len = strlen (pathbuf.get_win32 ()); + ssize_t len = MIN (buflen, pathbuf_len); memcpy (buf, pathbuf.get_win32 (), len); /* errno set by symlink.check if error */