diff --git a/HTMLparser.c b/HTMLparser.c
index 975099ca..ba886908 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -5056,8 +5056,7 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
htmlErrMemory(NULL, "htmlInitParserCtxt: out of memory\n");
return(-1);
}
- else
- memset(sax, 0, sizeof(htmlSAXHandler));
+ memset(sax, 0, sizeof(htmlSAXHandler));
/* Allocate the Input stack */
ctxt->inputTab = (htmlParserInputPtr *)
@@ -5116,11 +5115,9 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
ctxt->nodeInfoNr = 0;
ctxt->nodeInfoMax = 0;
- if (sax == NULL) ctxt->sax = (xmlSAXHandlerPtr) &htmlDefaultSAXHandler;
- else {
- ctxt->sax = sax;
- memcpy(sax, &htmlDefaultSAXHandler, sizeof(xmlSAXHandlerV1));
- }
+ ctxt->sax = sax;
+ xmlSAX2InitHtmlDefaultSAXHandler(sax);
+
ctxt->userData = ctxt;
ctxt->myDoc = NULL;
ctxt->wellFormed = 1;