Browse files

Temp var defined in global scope should be unset() after use

Fixes #15921
  • Loading branch information...
1 parent 67c9dea commit 41cdb926620f10256d970ef7404741a010d07b5d @dregad dregad committed May 25, 2013
Showing with 17 additions and 7 deletions.
  1. +4 −0 config_defaults_inc.php
  2. +4 −1 core.php
  3. +1 −0 core/custom_field_api.php
  4. +8 −6 core/plugin_api.php
View
4 config_defaults_inc.php
@@ -3969,3 +3969,7 @@
* - ''
*/
$g_mantistouch_url = '';
+
+
+ # Temporary variables should not remain defined in global scope
+ unset( $t_protocol, $t_host, $t_port, $t_self, $t_path, $t_use_iis );
@atrol
Mantis Bug Tracker member
atrol added a note May 26, 2013

$t_hosts is another candidate to unset

@dregad
Mantis Bug Tracker member
dregad added a note May 27, 2013

Missed that one, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
5 core.php
@@ -74,7 +74,7 @@
require_once( $t_local_config );
$t_config_inc_found = true;
}
-
+unset( $t_local_config );
# Attempt to find the location of the core files.
$t_core_path = dirname(__FILE__).DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR;
@@ -83,6 +83,7 @@
}
$g_core_path = $t_core_path;
+unset( $t_core_path );
/*
* Set include paths
@@ -160,6 +161,7 @@ function __autoload( $className ) {
echo var_dump($t_output);
die;
}
+unset( $t_output );
require_once( 'utility_api.php' );
require_once( 'compress_api.php' );
@@ -270,6 +272,7 @@ function __autoload( $className ) {
if ( file_exists( $t_overrides ) ) {
require_once( $t_overrides );
}
+unset( $t_overrides );
// set HTTP response headers
http_all_headers();
View
1 core/custom_field_api.php
@@ -57,6 +57,7 @@
foreach( $g_custom_field_types as $type ) {
require_once( 'cfdefs' . DIRECTORY_SEPARATOR . 'cfdef_' . $type . '.php' );
}
+unset( $type );
function custom_field_allow_manage_display( $p_type, $p_display ) {
global $g_custom_field_type_definition;
View
14 core/plugin_api.php
@@ -32,6 +32,8 @@
*/
require_once( $t_class_path . 'MantisPlugin.class.php' );
+unset( $t_class_path );
+
# Cache variables #####
$g_plugin_cache = array();
@@ -123,9 +125,9 @@ function plugin_file( $p_file, $p_redirect = false, $p_basename = null ) {
* @param string Plugin basename
*/
function plugin_file_include( $p_filename, $p_basename = null ) {
-
+
global $g_plugin_mime_types;
-
+
if( is_null( $p_basename ) ) {
$t_current = plugin_get_current();
} else {
@@ -136,17 +138,17 @@ function plugin_file_include( $p_filename, $p_basename = null ) {
if( false === $t_file_path ) {
trigger_error( ERROR_GENERIC, ERROR );
}
-
+
$t_content_type = '';
$finfo = finfo_get_if_available();
-
+
if ( $finfo ) {
$t_file_info_type = $finfo->file( $t_file_path );
if ( $t_file_info_type !== false ) {
$t_content_type = $t_file_info_type;
}
}
-
+
// allow overriding the content type for specific text and image extensions
// see bug #13193 for details
if ( strpos($t_content_type, 'text/') === 0 || strpos( $t_content_type, 'image/') === 0 ) {
@@ -158,7 +160,7 @@ function plugin_file_include( $p_filename, $p_basename = null ) {
if ( $t_content_type )
header('Content-Type: ' . $t_content_type );
-
+
readfile( $t_file_path );
}

0 comments on commit 41cdb92

Please sign in to comment.