diff --git a/ChangeLog b/ChangeLog
index 75e7cb16967f39ba7e10e78be8208cea3227b813_Q2hhbmdlTG9n..6ad0b7689328dddcaec0a560c93a81438b05bf1f_Q2hhbmdlTG9n 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Aug 20 14:02:00 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+	* parser.c: fixing bug #87900 
+
 May 24 13:10:22 CEST 2002 Daniel Veillard <daniel@veillard.com>
 
  	* libxml.spec.in: fixing bug #81112
diff --git a/parser.c b/parser.c
index 75e7cb16967f39ba7e10e78be8208cea3227b813_cGFyc2VyLmM=..6ad0b7689328dddcaec0a560c93a81438b05bf1f_cGFyc2VyLmM= 100644
--- a/parser.c
+++ b/parser.c
@@ -10985,6 +10985,7 @@
 			  char *buffer, int size) {
     int ret = 0;
     xmlParserCtxtPtr ctxt;
+    xmlSAXHandlerPtr oldsax;
     
     ctxt = xmlCreateMemoryParserCtxt(buffer, size);
     if (ctxt == NULL) return -1;
@@ -10988,7 +10989,10 @@
     
     ctxt = xmlCreateMemoryParserCtxt(buffer, size);
     if (ctxt == NULL) return -1;
-    ctxt->sax = sax;
+    if (sax != NULL) {
+	oldsax = ctxt->sax;
+	ctxt->sax = sax;
+    }
     ctxt->userData = user_data;
     
     xmlParseDocument(ctxt);
@@ -11002,7 +11006,7 @@
 	    ret = -1;
     }
     if (sax != NULL)
-	ctxt->sax = NULL;
+	ctxt->sax = oldsax;
     xmlFreeParserCtxt(ctxt);
     
     return ret;