@@ -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