fix crash/leaks from xmlSchematronParse due to improper schema document

* schematron.c: fix crash/leaks from xmlSchematronParse due to improper
  schema document ownership for bug #495215

svn path=/trunk/; revision=3663
diff --git a/ChangeLog b/ChangeLog
index b62d992..68cdf58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Nov 13 21:26:27 CET 2007 Rob Richards <rrichards@ctindustries.net>
+
+	* schematron.c: fix crash/leaks from xmlSchematronParse due to improper
+	  schema document ownership for bug #495215
+
 Tue Oct 30 21:24:55 CET 2007 Daniel Veillard <daniel@veillard.com>
 
 	* xmlmemory.c: xmlFree(NULL) should not crash in debug mode
diff --git a/schematron.c b/schematron.c
index a2eabcc..146ffc9 100644
--- a/schematron.c
+++ b/schematron.c
@@ -1204,6 +1204,9 @@
     }
     /* the original document must be kept for reporting */
     ret->doc = doc;
+    if (preserve) {
+	    ret->preserve = 1;
+    }
     preserve = 1;
 
 exit: