From ef2357ce486be9df8ed48dc2efa71fada3696a77 Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Thu, 19 May 2011 23:09:58 +0000 Subject: [PATCH] Fix bug 54866 --- TSRM/tsrm_virtual_cwd.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index b88bae90a8..ca9809b104 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -617,7 +617,13 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ memcmp(path, (*bucket)->path, path_len) == 0) { realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1; + + /* if the pointers match then only subtract the length of the path */ + if(r->path == r->realpath) + CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; + else + CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1; + free(r); return; } else { @@ -692,7 +698,13 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p if (CWDG(realpath_cache_ttl) && (*bucket)->expires < t) { realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1; + + /* if the pointers match then only subtract the length of the path */ + if(r->path == r->realpath) + CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; + else + CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1; + free(r); } else if (key == (*bucket)->key && path_len == (*bucket)->path_len && memcmp(path, (*bucket)->path, path_len) == 0) { -- 2.40.0