Skip to content

Commit e40c470

Browse files
committed
Fix bug 54866
1 parent 221a07b commit e40c470

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

NEWS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ PHP NEWS
3232
(tomas dot brastavicius at quantum dot lt, Pierrick)
3333
. Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using
3434
TMPDIR on Windows). (Pierre)
35+
. Fixed bug 54866 (incorrect accounting for realpath_cache_size) (Dustin Ward)
3536

36-
- cURL
37+
- cURL:
3738
. Added CURLINFO_REDIRECT_URL support. (Daniel Stenberg, Pierre)
3839
. Added support for CURLOPT_MAX_RECV_SPEED_LARGE and
3940
CURLOPT_MAX_SEND_SPEED_LARGE. FR #51815. (Pierrick)

TSRM/tsrm_virtual_cwd.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,13 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{
629629
memcmp(path, (*bucket)->path, path_len) == 0) {
630630
realpath_cache_bucket *r = *bucket;
631631
*bucket = (*bucket)->next;
632-
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
632+
633+
/* if the pointers match then only subtract the length of the path */
634+
if(r->path == r->realpath)
635+
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1;
636+
else
637+
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
638+
633639
free(r);
634640
return;
635641
} else {
@@ -704,7 +710,13 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p
704710
if (CWDG(realpath_cache_ttl) && (*bucket)->expires < t) {
705711
realpath_cache_bucket *r = *bucket;
706712
*bucket = (*bucket)->next;
707-
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
713+
714+
/* if the pointers match then only subtract the length of the path */
715+
if(r->path == r->realpath)
716+
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1;
717+
else
718+
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
719+
708720
free(r);
709721
} else if (key == (*bucket)->key && path_len == (*bucket)->path_len &&
710722
memcmp(path, (*bucket)->path, path_len) == 0) {

0 commit comments

Comments
 (0)