Skip to content

Commit 01a6840

Browse files
committed
Fix bug 54866
1 parent 3012b74 commit 01a6840

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

TSRM/tsrm_virtual_cwd.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,13 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{
617617
memcmp(path, (*bucket)->path, path_len) == 0) {
618618
realpath_cache_bucket *r = *bucket;
619619
*bucket = (*bucket)->next;
620-
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
620+
621+
/* if the pointers match then only subtract the length of the path */
622+
if(r->path == r->realpath)
623+
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1;
624+
else
625+
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
626+
621627
free(r);
622628
return;
623629
} else {
@@ -692,7 +698,13 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p
692698
if (CWDG(realpath_cache_ttl) && (*bucket)->expires < t) {
693699
realpath_cache_bucket *r = *bucket;
694700
*bucket = (*bucket)->next;
695-
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
701+
702+
/* if the pointers match then only subtract the length of the path */
703+
if(r->path == r->realpath)
704+
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1;
705+
else
706+
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
707+
696708
free(r);
697709
} else if (key == (*bucket)->key && path_len == (*bucket)->path_len &&
698710
memcmp(path, (*bucket)->path, path_len) == 0) {

0 commit comments

Comments
 (0)