Index: menu.inc
===================================================================
--- menu.inc	(revision 2)
+++ menu.inc	(working copy)
@@ -1504,6 +1504,9 @@
       }
     }
 
+    $menu_link = menu_link_load(db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", $item['path'])));
+    menu_set_active_menu_name($menu_link['menu_name']);
+
     $tree = menu_tree_page_data(menu_get_active_menu_name());
     list($key, $curr) = each($tree);
 
@@ -1515,7 +1518,7 @@
       }
       else {
         // Move to the child link if it's in the active trail.
-        if ($curr['below'] && $curr['link']['in_active_trail']) {
+        if (is_array($curr['below']) && $curr['link']['in_active_trail']) {
           $trail[] = $curr['link'];
           $tree = $curr['below'];
         }
