Index: webform.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v
retrieving revision 1.124.2.110
diff -u -r1.124.2.110 webform.module
--- webform.module	7 Feb 2010 23:34:37 -0000	1.124.2.110
+++ webform.module	10 Feb 2010 00:28:21 -0000
@@ -492,7 +492,7 @@
   }
 
   // Set the per-role submission access control.
-  foreach (array_filter($node->webform['roles']) as $rid => $value) {
+  foreach ($node->webform['roles'] as $rid) {
     db_query('INSERT INTO {webform_roles} (nid, rid) VALUES (%d, %d)', $node->nid, $rid);
   }
 }
@@ -1028,6 +1028,9 @@
     $node->webform['submit_interval'] = -1;
   }
   unset($node->webform['enforce_limit']);
+
+  // Save roles.
+  $node->webform['roles'] = array_keys(array_filter($node->webform['roles']));
 }
 
 /**
@@ -2000,7 +2003,7 @@
   if (isset($vars['form']['details']['nid']['#value'])) {
     $vars['nid'] = $vars['form']['details']['nid']['#value'];
   }
-  else {
+  elseif (isset($vars['form']['submission']['#value'])) {
     $vars['nid'] = $vars['form']['submission']['#value']->nid;
   }
 }
