Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.174.2.17
diff -u -p -r1.174.2.17 form.inc
--- includes/form.inc	26 Feb 2009 05:50:33 -0000	1.174.2.17
+++ includes/form.inc	16 Apr 2009 06:01:03 -0000
@@ -497,6 +497,12 @@ function drupal_redirect_form($form, $re
     $goto = $form['#redirect'];
   }
   if ($goto !== FALSE) {
+    // Remove any fake destination set by drupal_not_found() or
+    // drupal_access_denied() so that we can properly redirect from those
+    // pages.
+    if (isset($_REQUEST['destination']) && $_REQUEST['destination'] == $_REQUEST['q'] && $_GET['q'] === '') {
+      unset($_REQUEST['destination']);
+    }
     if (is_array($goto)) {
       call_user_func_array('drupal_goto', $goto);
     }
