Index: /trunk/psLib/src/types/psMetadata.c
===================================================================
--- /trunk/psLib/src/types/psMetadata.c	(revision 7910)
+++ /trunk/psLib/src/types/psMetadata.c	(revision 7911)
@@ -12,6 +12,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.115 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-06-30 02:20:06 $
+ *  @version $Revision: 1.116 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-07-15 02:37:47 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -127,4 +127,5 @@
     if (iter->regex != NULL) {
         regfree(iter->regex);
+        psFree(iter->regex);
     }
 }
@@ -918,8 +919,8 @@
     psMemSetDeallocator(newIter, (psFreeFunc) metadataIteratorFree);
 
-    if (regex == NULL) {
-        newIter->iter = psListIteratorAlloc(md->list, location, false);
-        return newIter;
-    } else {
+    newIter->iter = psListIteratorAlloc(md->list, location, false);
+
+    if (regex) {
+        newIter->regex = psAlloc(sizeof(regex_t));
         int regRtn = regcomp(newIter->regex,regex,0);
         if (regRtn != 0) {
@@ -934,6 +935,4 @@
         }
     }
-
-    psMetadataIteratorSet(newIter, location); // XXX: do we error if no match is found?
 
     return newIter;
@@ -1011,5 +1010,5 @@
     while (psListGetAndIncrement(iter) != NULL) {
         if (iter->cursor != NULL &&
-                regexec(regex, ((psMetadataItem*)iter->cursor)->name, 0, NULL, 0) == 0) {
+                regexec(regex, ((psMetadataItem*)iter->cursor->data)->name, 0, NULL, 0) == 0) {
             // this key is a match
             break;
