NS_IF_RELEASE(mDocumentBaseURL);
XULContentSinkImpl::~XULContentSinkImpl(){    // There shouldn't be any here except in an error condition    PRInt32 index = mNameSpaceStack.Count();    while (0 < index--) {        nsINameSpace* nameSpace = (nsINameSpace*)mNameSpaceStack[index];#ifdef PR_LOGGING        if (PR_LOG_TEST(gLog, PR_LOG_ALWAYS)) {            nsAutoString uri;            nsCOMPtr<nsIAtom> prefixAtom;            nameSpace->GetNameSpaceURI(uri);            nameSpace->GetNameSpacePrefix(*getter_AddRefs(prefixAtom));            nsAutoString prefix;            if (prefixAtom)                prefix = prefixAtom->GetUnicode();            else                prefix = "<default>";            char* prefixStr = prefix.ToNewCString();            char* uriStr = uri.ToNewCString();            PR_LOG(gLog, PR_LOG_ALWAYS,                   ("xul: warning: unclosed namespace '%s' (%s)",                    prefixStr, uriStr));            delete[] prefixStr;            delete[] uriStr;        }#endif        NS_RELEASE(nameSpace);    }    if (mContextStack) {        // XXX we should never need to do this, but, we'll write the        // code all the same. If someone left the content stack dirty,        // pop all the elements off the stack and release them.        PRInt32 index = mContextStack->Count();        while (0 < index--) {            nsIRDFResource* resource;            XULContentSinkState state;            PopResourceAndState(resource, state);#ifdef PR_LOGGING            if (PR_LOG_TEST(gLog, PR_LOG_ALWAYS)) {                nsAutoString tag("unknown");                nsAutoString nameSpaceURI("unknown");                nsresult rv;                nsCOMPtr<nsIRDFNode> typeNode;                // pull the namespace and tag out of the resource by                // walking the 'type' arc.                rv = mDataSource->GetTarget(resource, kRDF_type, PR_TRUE, getter_AddRefs(typeNode));                if (NS_OK == rv) {                    nsCOMPtr<nsIRDFResource> type( do_QueryInterface(typeNode) );                    if (type) {                        nsCOMPtr<nsIRDFDocument> rdfDoc( do_QueryInterface(mDocument) );                        if (rdfDoc) {                            PRInt32 nameSpaceID;                            nsCOMPtr<nsIAtom> tagAtom;                            rv = rdfDoc->SplitProperty(type, &nameSpaceID, getter_AddRefs(tagAtom));                            if (NS_SUCCEEDED(rv)) {                                tag = tagAtom->GetUnicode();                                mNameSpaceManager->GetNameSpaceURI(nameSpaceID, nameSpaceURI);                            }                        }                    }                }                char* tagStr = tag.ToNewCString();                char* nameSpaceURIStr = nameSpaceURI.ToNewCString();                                PR_LOG(gLog, PR_LOG_ALWAYS,                       ("xul: warning: unclosed tag '%s' in namepace '%s'",                        tagStr, nameSpaceURIStr));                delete[] tagStr;                delete[] nameSpaceURIStr;            }#endif            NS_IF_RELEASE(resource);        }        delete mContextStack;    }    NS_IF_RELEASE(mNameSpaceManager);    NS_IF_RELEASE(mDocumentURL);    NS_IF_RELEASE(mDataSource);    NS_IF_RELEASE(mDocument);    NS_IF_RELEASE(mParser);    NS_IF_RELEASE(mFragmentRoot);    PR_FREEIF(mText);    if (--gRefCnt == 0) {        nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);        NS_IF_RELEASE(kRDF_child);        NS_IF_RELEASE(kRDF_instanceOf);        NS_IF_RELEASE(kRDF_type);        NS_IF_RELEASE(kXUL_element);    }}