php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50101 [PATCH] - Avoid name clash between global and local variable
Submitted: 2009-11-06 12:41 UTC Modified: 2010-06-08 15:27 UTC
From: yoarvi at gmail dot com Assigned: tony2001 (profile)
Status: Closed Package: Compile Failure
PHP Version: 6SVN-2009-11-06 (SVN) OS: Solaris 5.10 (SPARC)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: yoarvi at gmail dot com
New email:
PHP Version: OS:

 

 [2009-11-06 12:41 UTC] yoarvi at gmail dot com
Description:
------------
TSRM/tsrm_virtual_cwd.c uses the same name for a global variable as well as for arguments to a function (when #ifndef ZTS).

#ifdef ZTS
ts_rsrc_id cwd_globals_id;
#else
virtual_cwd_globals cwd_globals;
#endif


static void cwd_globals_ctor(virtual_cwd_globals *cwd_globals TSRMLS_DC) /* {{{ */

static void cwd_globals_dtor(virtual_cwd_globals *cwd_globals TSRMLS_DC) /* {{{ */


Reproduce code:
---------------
The following patch avoids the name clash:

diff -r f2728a22d214 TSRM/tsrm_virtual_cwd.c
--- a/TSRM/tsrm_virtual_cwd.c	Fri Nov 06 18:07:39 2009 +0530
+++ b/TSRM/tsrm_virtual_cwd.c	Fri Nov 06 18:13:55 2009 +0530
@@ -262,19 +262,19 @@
 }
 /* }}} */
 
-static void cwd_globals_ctor(virtual_cwd_globals *cwd_globals TSRMLS_DC) /* {{{ */
+static void cwd_globals_ctor(virtual_cwd_globals *cwdg TSRMLS_DC) /* {{{ */
 {
-	CWD_STATE_COPY(&cwd_globals->cwd, &main_cwd_state);
-	cwd_globals->realpath_cache_size = 0;
-	cwd_globals->realpath_cache_size_limit = REALPATH_CACHE_SIZE;
-	cwd_globals->realpath_cache_ttl = REALPATH_CACHE_TTL;
-	memset(cwd_globals->realpath_cache, 0, sizeof(cwd_globals->realpath_cache));
+	CWD_STATE_COPY(&cwdg->cwd, &main_cwd_state);
+	cwdg->realpath_cache_size = 0;
+	cwdg->realpath_cache_size_limit = REALPATH_CACHE_SIZE;
+	cwdg->realpath_cache_ttl = REALPATH_CACHE_TTL;
+	memset(cwdg->realpath_cache, 0, sizeof(cwdg->realpath_cache));
 }
 /* }}} */
 
-static void cwd_globals_dtor(virtual_cwd_globals *cwd_globals TSRMLS_DC) /* {{{ */
+static void cwd_globals_dtor(virtual_cwd_globals *cwdg TSRMLS_DC) /* {{{ */
 {
-	CWD_STATE_FREE(&cwd_globals->cwd);
+	CWD_STATE_FREE(&cwdg->cwd);
 	realpath_cache_clean(TSRMLS_C);
 }
 /* }}} */

Expected result:
----------------
Disambiguity.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-08 15:27 UTC] tony2001@php.net
Automatic comment from SVN on behalf of tony2001
Revision: http://svn.php.net/viewvc/?view=revision&revision=300276
Log: fix bug #50101 (name clash between global and local variable)
 [2010-06-08 15:27 UTC] tony2001@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: tony2001
 [2010-06-08 15:27 UTC] tony2001@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC