Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.177
diff -u -r1.177 theme.inc
--- includes/theme.inc	22 Dec 2003 22:54:59 -0000	1.177
+++ includes/theme.inc	2 Jan 2004 15:52:09 -0000
@@ -40,18 +40,11 @@
   global $user;
 
   $themes = list_themes();
-  $name = $user->theme ? $user->theme : variable_get("theme_default", 0);
+  /* Only render the user selected theme if it is availible in the list of enabled themes. */
+  $theme_name = (in_array($user->theme, $themes)) ? $user->theme : variable_get("theme_default", 0);
+  include_once($themes[$theme_name]->filename);
 
-  $theme->path = "";
-  $theme->name = "";
-
-  if (is_object($themes[$name])) {
-    include_once($themes[$name]->filename);
-    $theme->path = dirname($themes[$name]->filename);
-    $theme->name = $name;
-  }
-
-  return $theme;
+  return $theme_name;
 }
 
 /**
@@ -97,8 +90,8 @@
   $args = func_get_args();
   $function = array_shift($args);
 
-  if (($theme->name != "") && (function_exists($theme->name ."_". $function))) {
-    return call_user_func_array($theme->name ."_". $function, $args);
+  if (($theme != "") && (function_exists($theme ."_". $function))) {
+    return call_user_func_array($theme ."_". $function, $args);
   }
   elseif (function_exists("theme_". $function)){
     return call_user_func_array("theme_". $function, $args);
@@ -112,7 +105,10 @@
  */
 function path_to_theme() {
   global $theme;
-  return $theme->path;
+
+  $themes = list_themes();
+
+  return dirname($themes[$theme]->filename);
 }
 
 /**
