Index: wp-includes/theme.php
--- wp-includes/theme.php Base
+++ wp-includes/theme.php Locally Modified
@@ -1552,14 +1552,15 @@
  */
 function check_theme_switched() {
 	if ( $stylesheet = get_option( 'theme_switched' ) ) {
-		$old_theme = wp_get_theme( $stylesheet );
+		if ( $old_theme = wp_get_theme( $stylesheet ) ) {
+			if ( $old_theme->exists() ) {
+				do_action( 'after_switch_theme', $old_theme->get('Name'), $old_theme );
+			} else {
+				do_action( 'after_switch_theme', $stylesheet );
+			}
 
-		if ( $old_theme->exists() )
-			do_action( 'after_switch_theme', $old_theme->get('Name'), $old_theme );
-		else
-			do_action( 'after_switch_theme', $stylesheet );
-
-		update_option( 'theme_switched', false );
+			update_option( 'theme_switched', false );
+		}
 	}
 }
 
