Re: Firefox crash When using rdf:files in a composite datasource with my rdf datasource component!

BenKwan <[email protected]> Mon, 22 Jun 2009 22:33:20 -0700 (PDT)
Newsgroups gmane.comp.mozilla.devel.rdf
Organization http://groups.google.com
Message-ID <93752e85-3661-4c1b-b720-13d32b980b96@x31g2000prc.googlegroups.com>
I debuged in the debug version xulrunner and find that it crashs in
the method "IsEmpty" of RDFContainerUtilsImpl in the mozilla\rdf\base
\src\nsRDFContainerUtils.cpp. It crashs because of using null ptr at
this code snippet:
/////////////////////////////////////////////////////
NS_IMETHODIMP
RDFContainerUtilsImpl::IsEmpty(nsIRDFDataSource* aDataSource,
nsIRDFResource* aResource, PRBool* _retval)
{
    if (! aDataSource)
        return NS_ERROR_NULL_POINTER;

    nsresult rv;

    // By default, say that we're an empty container. Even if we're
not
    // really even a container.
    *_retval = PR_TRUE;

    nsCOMPtr<nsIRDFNode> nextValNode;
    rv = aDataSource->GetTarget(aResource, kRDF_nextVal, PR_TRUE,
getter_AddRefs(nextValNode));  //the problem is caused here!
    if (NS_FAILED(rv)) return rv;

	//NS_ENSURE_TRUE(nextValNode,NS_ERROR_NULL_POINTER); //the code i
Add,uncomment it and it goes good!

    if (rv == NS_RDF_NO_VALUE)
        return NS_OK;

    nsCOMPtr<nsIRDFLiteral> nextValLiteral;
    rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral),
getter_AddRefs(nextValLiteral)); //nextValNode is null,it crash!
    if (NS_FAILED(rv)) return rv;

    if (nextValLiteral.get() != kOne)
        *_retval = PR_FALSE;

    return NS_OK;
}
/////////////////////////////////////////////////////

when my tree is:
<tree id="filelisttree" flex="1" datasources="rdf:files"
ref="NC:FilesRoot">

OR

<tree id="filelisttree_ben" flex="1" datasources="rdf:files
chrome://test/content/filerdf.rdf" ref="http://
addressbook.desktopx.org/rdfroot">

the nextValNode got from "GetTarget" is null and the return value rv
is non-zero,so it goes good;but when my tree is :
<tree id="filelisttree_ben1" flex="1" datasources="rdf:files
rdf:cefilerdfdatasource" ref="http://addressbook.desktopx.org/
rdf#root">

the nextValNode is also null,but the return value rv is 0,so when go
to this sentence:

rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral),
getter_AddRefs(nextValLiteral));

it crash!

when i add "NS_ENSURE_TRUE(nextValNode,NS_ERROR_NULL_POINTER);" in the
method,everything is OK.Why the retrun value is so different?Is it a
bug?

My test is here:
http://sites.google.com/site/freebendy/Home/test.rar?attredirects=0

PS:
  placed the folder "test" and test.manifest in the chrome
directory,dxfilerdf.js file in components directory. Delete the
comreg.dat and xpti,dat in the profile directory!