php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #54866
Patch realpath_cache_accounting_bug revision 2011-05-19 20:05 UTC by dustin dot ward1 at gmail dot com

Patch realpath_cache_accounting_bug for *Directory/Filesystem functions Bug #54866

Patch version 2011-05-19 20:05 UTC

Return to Bug #54866 | Download this patch
Patch Revisions:

Developer: dustin.ward1@gmail.com

--- php/TSRM/tsrm_virtual_cwd.c	2010-11-03 20:16:20.000000000 -0500
+++ /home/dward/tsrm_virtual_cwd.c	2011-05-19 14:16:20.000000000 -0500
@@ -623,7 +623,13 @@
 					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 {
@@ -694,7 +700,13 @@
 		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) {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC