Skip to content

Commit

Permalink
Bug 1297300 - Add missing checks to GetSpec() calls in rdf/, startupc…
Browse files Browse the repository at this point in the history
…ache/ and xpfe/. r=froydnj.
  • Loading branch information
nnethercote committed Aug 30, 2016
1 parent 33c5b34 commit 676dc35
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
6 changes: 4 additions & 2 deletions rdf/base/nsRDFService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,8 +1298,10 @@ RDFServiceImpl::GetDataSource(const char* aURI, bool aBlock, nsIRDFDataSource**
if (!StringBeginsWith(spec, NS_LITERAL_CSTRING("rdf:"))) {
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), spec);
if (uri)
uri->GetSpec(spec);
if (uri) {
rv = uri->GetSpec(spec);
if (NS_FAILED(rv)) return rv;
}
}

// First, check the cache to see if we already have this
Expand Down
7 changes: 4 additions & 3 deletions rdf/base/nsRDFXMLDataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,14 +604,15 @@ RDFXMLDataSourceImpl::GetURI(char* *aURI)
if (!mURL) {
return NS_OK;
}

nsAutoCString spec;
mURL->GetSpec(spec);
nsresult rv = mURL->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
*aURI = ToNewCString(spec);
if (!*aURI) {
return NS_ERROR_OUT_OF_MEMORY;
}

return NS_OK;
}

Expand Down
9 changes: 7 additions & 2 deletions startupcache/test/TestStartupCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ TestWriteObject() {
return NS_ERROR_UNEXPECTED;
}
NS_NAMED_LITERAL_CSTRING(spec, "http://www.mozilla.org");
obj->SetSpec(spec);
rv = obj->SetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStartupCache> sc = do_GetService("@mozilla.org/startupcache/cache;1", &rv);

sc->InvalidateCache();
Expand Down Expand Up @@ -232,7 +233,11 @@ TestWriteObject() {
nsCOMPtr<nsIURI> uri(do_QueryInterface(deserialized));
if (uri) {
nsCString outSpec;
uri->GetSpec(outSpec);
rv = uri->GetSpec(outSpec);
if (NS_FAILED(rv)) {
fail("failed to get spec");
return rv;
}
match = outSpec.Equals(spec);
}
if (!match) {
Expand Down
7 changes: 4 additions & 3 deletions xpfe/components/directory/nsDirectoryViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,14 @@ nsHTTPIndex::OnStartRequest(nsIRequest *request, nsISupports* aContext)
// now create the top most resource
nsCOMPtr<nsIURI> uri;
channel->GetURI(getter_AddRefs(uri));

nsAutoCString entryuriC;
uri->GetSpec(entryuriC);
rv = uri->GetSpec(entryuriC);
if (NS_FAILED(rv)) return rv;

nsCOMPtr<nsIRDFResource> entry;
rv = mDirRDF->GetResource(entryuriC, getter_AddRefs(entry));

NS_ConvertUTF8toUTF16 uriUnicode(entryuriC);

nsCOMPtr<nsIRDFLiteral> URLVal;
Expand Down

0 comments on commit 676dc35

Please sign in to comment.