diff --git a/src/xercesc/dom/impl/DOMParentNode.cpp b/src/xercesc/dom/impl/DOMParentNode.cpp
index e5fd5a06080a12a62f1c4d01e87112124764847b..3d1a976e68dded535809b21ac98e6831e5c0a686 100644
--- a/src/xercesc/dom/impl/DOMParentNode.cpp
+++ b/src/xercesc/dom/impl/DOMParentNode.cpp
@@ -139,6 +139,10 @@ bool DOMParentNode::hasChildNodes() const
 
 
 DOMNode *DOMParentNode::insertBefore(DOMNode *newChild, DOMNode *refChild) {
+    //not really in the specs, but better than nothing
+    if(newChild==NULL)
+        throw DOMException(DOMException::HIERARCHY_REQUEST_ERR,0, GetDOMParentNodeMemoryManager);
+
     DOMNodeImpl *thisNodeImpl = castToNodeImpl(this);
     if (thisNodeImpl->isReadOnly())
         throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMParentNodeMemoryManager);