Index: wp-includes/capabilities.php
===================================================================
--- wp-includes/capabilities.php	(revision 18589)
+++ wp-includes/capabilities.php	(working copy)
@@ -176,6 +176,9 @@
 	 * @param bool $grant Optional, default is true. Whether role is capable of performing capability.
 	 */
 	function add_cap( $role, $cap, $grant = true ) {
+		if ( ! isset( $this->roles[$role] ) )
+			return;
+
 		$this->roles[$role]['capabilities'][$cap] = $grant;
 		if ( $this->use_db )
 			update_option( $this->role_key, $this->roles );
@@ -191,6 +194,9 @@
 	 * @param string $cap Capability name.
 	 */
 	function remove_cap( $role, $cap ) {
+		if ( ! isset( $this->roles[$role] ) )
+			return;
+
 		unset( $this->roles[$role]['capabilities'][$cap] );
 		if ( $this->use_db )
 			update_option( $this->role_key, $this->roles );
