diff --git a/src/internal/ElemStack.cpp b/src/internal/ElemStack.cpp
index f70a13a313cc6e287275c0194ae1d1e1b32cf80f..9ebcefa1b08f285d8210161e38131f08d7abc228 100644
--- a/src/internal/ElemStack.cpp
+++ b/src/internal/ElemStack.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.13  2001/06/12 19:08:27  peiyongz
+ * Memory leak: fixed by Erik Rydgren
+ *
  * Revision 1.12  2001/05/28 20:55:19  tng
  * Schema: Store Grammar in ElemStack as well.
  *
@@ -146,6 +149,9 @@ ElemStack::~ElemStack()
             break;
 
         // Delete the row for this entry, then delete the row structure
+        for (unsigned int childIndex = 0; childIndex < fStack[stackInd]->fChildCount; ++childIndex)
+            delete fStack[stackInd]->fChildren[childIndex];
+
         delete [] fStack[stackInd]->fChildren;
         delete [] fStack[stackInd]->fMap;
         delete fStack[stackInd];
diff --git a/src/validators/common/DFAContentModel.cpp b/src/validators/common/DFAContentModel.cpp
index 09e31a79bb5ede7c1d544710f0638a0bf94af555..79f4cbd875dd6f7366d5f0fd4c0e82e08d818ea7 100644
--- a/src/validators/common/DFAContentModel.cpp
+++ b/src/validators/common/DFAContentModel.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.13  2001/06/12 19:07:14  peiyongz
+ * Memory leak: fixed by Erik Rydgren
+ *
  * Revision 1.12  2001/06/12 17:30:49  knoaman
  * Fix Typo
  *
@@ -174,8 +177,12 @@ DFAContentModel::~DFAContentModel()
         delete [] fTransTable[index];
     delete [] fTransTable;
 
+    for (index = 0; index < fLeafCount; index++)
+        delete fElemMap[index];
     delete [] fElemMap;
+
     delete [] fElemMapType;
+    delete [] fLeafListType;
 }
 
 
@@ -321,7 +328,7 @@ int DFAContentModel::validateContentSpecial(QName** const          children
             ContentSpecNode::NodeTypes type = fElemMapType[elemIndex];
             if (type == ContentSpecNode::Leaf)
             {
-                if (comparator.isEquivalentTo(curElem, inElem))
+                if (comparator.isEquivalentTo(curElem, inElem) )
                 {
                     nextState = fTransTable[curState][elemIndex];
                     if (nextState != XMLContentModel::gInvalidTrans)
@@ -786,18 +793,22 @@ void DFAContentModel::buildDFA(ContentSpecNode* const curNode)
     //  Now we can clean up all of the temporary data that was needed during
     //  DFA build.
     //
-    delete fHeadNode;
+
+    // the CMBinary will be released by fLeafList[]
+    //delete fHeadNode;
     fHeadNode = 0;
 
     for (index = 0; index < fLeafCount; index++)
         delete fFollowList[index];
+    delete [] fFollowList;
 
     for (index = 0; index < curState; index++)
         delete (CMStateSet*)statesToDo[index];
+    delete [] statesToDo;
 
+    for (index = 0; index < fLeafCount; index++)
+        delete fLeafList[index];
     delete [] fLeafList;
-    delete [] fFollowList;
-    delete [] statesToDo;
 
 	delete [] fLeafSorter;
 }