--- patterns.module.orig	2009-04-27 13:35:51.000000000 +0200
+++ patterns.module	2009-04-27 13:58:18.000000000 +0200
@@ -1135,18 +1135,20 @@ function patterns_from_source($xml) {
 function _patterns_parse_tag($data, &$index = 0) {
   $pattern = array();
 
-  while ($current = $data[$index]) {
+  while (isset($data[$index]) && $current = $data[$index]) {
     $type = $current['type'];
 
-    foreach((array)$current['attributes'] as $key => $value) {
-      $current[strtolower($key)] = $value;
-    }
+		if(isset($current['attributes'])) {
+			foreach((array)$current['attributes'] as $key => $value) {
+				$current[strtolower($key)] = $value;
+			}
+		}
 
     $current['tag'] = strtolower($current['tag']);
 
     unset($current['type'], $current['level'], $current['attributes']);
 
-    if (!trim($current['value']) && $current['value'] != "0") {
+    if (isset($current['value']) && !trim($current['value']) && $current['value'] != "0") {
       unset($current['value']);
     }
 
@@ -1162,7 +1164,7 @@ function _patterns_parse_tag($data, &$in
         break;
       case 'complete':
         // In order to support more complex/non-standard features we can use serialized data
-        if ($current['attributes']['serialized']) {
+        if (isset($current['attributes']) && $current['attributes']['serialized']) {
           $value = unserialize($current['value']);
 
           if (isset($value)) {
@@ -3014,4 +3016,4 @@ function patterns_debug_batch($var = nul
   $var = str_replace("\n", "<br />", $var);
   print drupal_to_js(array('status' => 0, 'data' => $var));
   exit;
-}
\ No newline at end of file
+}
