Index: src/wp-includes/general-template.php
===================================================================
--- src/wp-includes/general-template.php	(revision 37300)
+++ src/wp-includes/general-template.php	(working copy)
@@ -895,10 +895,6 @@
 		);
 	}
 
-	if ( is_multisite() && ms_is_switched() ) {
-		restore_current_blog();
-	}
-
 	/**
 	 * Filter the custom logo output.
 	 *
@@ -905,8 +901,15 @@
 	 * @since 4.5.0
 	 *
 	 * @param string $html Custom logo HTML output.
+	 * @param int $blog_id ID of the blog in question. Default is the ID of the current blog.
 	 */
-	return apply_filters( 'get_custom_logo', $html );
+	$html = apply_filters( 'get_custom_logo', $html, $blog_id );
+
+	if ( is_multisite() && ms_is_switched() ) {
+		restore_current_blog();
+	}
+
+	return $html;
 }
 
 /**
