summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-09-13 17:58:47 +0200
committerAnatol Belski <ab@php.net>2014-09-13 23:21:40 +0200
commit586b863ba754a19495f4abaadd32df85a394616d (patch)
tree3916ce156a1c1923cd25194e5f8c797cbd02f740 /main
parent47fb7a46ac1ff29b065fd5e46b0c3174e7e2b2a0 (diff)
downloadphp-git-586b863ba754a19495f4abaadd32df85a394616d.tar.gz
avoid multiple strlen() calls for the same
Diffstat (limited to 'main')
-rw-r--r--main/fopen_wrappers.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index e375bdf413..b0eec9a85e 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -758,10 +758,11 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co
cwd_state new_state;
char cwd[MAXPATHLEN];
int copy_len;
+ int path_len = strlen(filepath);
if (!filepath[0]) {
return NULL;
- } else if (IS_ABSOLUTE_PATH(filepath, strlen(filepath))) {
+ } else if (IS_ABSOLUTE_PATH(filepath, path_len)) {
cwd[0] = '\0';
} else {
const char *iam = SG(request_info).path_translated;
@@ -784,7 +785,7 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co
/* return a relative file path if for any reason
* we cannot cannot getcwd() and the requested,
* relatively referenced file is accessible */
- copy_len = strlen(filepath) > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : strlen(filepath);
+ copy_len = path_len > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : path_len;
if (real_path) {
memcpy(real_path, filepath, copy_len);
real_path[copy_len] = '\0';