Bug 800603: Just check rv (not rv & outparam) after calling imgIRequest:GetImage & GetImagePrincipal. r=jrmuizel

This commit is contained in:
Daniel Holbert 2012-10-16 16:05:54 -07:00
parent 0516389cc0
commit 2b0d34fc2f
3 changed files with 15 additions and 18 deletions

View File

@ -2834,8 +2834,8 @@ DrawBorderImage(nsPresContext* aPresContext,
// Get the actual image.
nsCOMPtr<imgIContainer> imgContainer;
req->GetImage(getter_AddRefs(imgContainer));
NS_ASSERTION(imgContainer, "no image to draw");
DebugOnly<nsresult> rv = req->GetImage(getter_AddRefs(imgContainer));
NS_ASSERTION(NS_SUCCEEDED(rv) && imgContainer, "no image to draw");
nsIntSize imageSize;
if (NS_FAILED(imgContainer->GetWidth(&imageSize.width))) {
@ -4033,7 +4033,7 @@ nsImageRenderer::PrepareImage()
nsCOMPtr<imgIContainer> img;
if (!((mFlags & FLAG_SYNC_DECODE_IMAGES) &&
(mType == eStyleImageType_Image) &&
(NS_SUCCEEDED(mImage->GetImageData()->GetImage(getter_AddRefs(img))) && img)))
(NS_SUCCEEDED(mImage->GetImageData()->GetImage(getter_AddRefs(img))))))
return false;
}
}
@ -4042,9 +4042,11 @@ nsImageRenderer::PrepareImage()
case eStyleImageType_Image:
{
nsCOMPtr<imgIContainer> srcImage;
mImage->GetImageData()->GetImage(getter_AddRefs(srcImage));
NS_ABORT_IF_FALSE(srcImage, "If srcImage is null, mImage->IsComplete() "
"should have returned false");
DebugOnly<nsresult> rv =
mImage->GetImageData()->GetImage(getter_AddRefs(srcImage));
NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv) && srcImage,
"If GetImage() is failing, mImage->IsComplete() "
"should have returned false");
if (!mImage->GetCropRect()) {
mImageContainer.swap(srcImage);
@ -4465,8 +4467,7 @@ nsImageRenderer::IsRasterImage()
if (mType != eStyleImageType_Image)
return false;
nsCOMPtr<imgIContainer> img;
nsresult rv = mImage->GetImageData()->GetImage(getter_AddRefs(img));
if (NS_FAILED(rv) || !img)
if (NS_FAILED(mImage->GetImageData()->GetImage(getter_AddRefs(img))))
return false;
return img->GetType() == imgIContainer::TYPE_RASTER;
}
@ -4478,7 +4479,7 @@ nsImageRenderer::GetContainer()
return nullptr;
nsCOMPtr<imgIContainer> img;
nsresult rv = mImage->GetImageData()->GetImage(getter_AddRefs(img));
if (NS_FAILED(rv) || !img)
if (NS_FAILED(rv))
return nullptr;
nsRefPtr<ImageContainer> container;
rv = img->GetImageContainer(getter_AddRefs(container));

View File

@ -4291,12 +4291,12 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
nsCOMPtr<nsIPrincipal> principal;
rv = imgRequest->GetImagePrincipal(getter_AddRefs(principal));
if (NS_FAILED(rv) || !principal)
if (NS_FAILED(rv))
return result;
nsCOMPtr<imgIContainer> imgContainer;
rv = imgRequest->GetImage(getter_AddRefs(imgContainer));
if (NS_FAILED(rv) || !imgContainer)
if (NS_FAILED(rv))
return result;
uint32_t whichFrame = (aSurfaceFlags & SFE_WANT_FIRST_FRAME)
@ -4786,9 +4786,7 @@ nsLayoutUtils::RegisterImageRequestIfAnimated(nsPresContext* aPresContext,
if (aRequest) {
nsCOMPtr<imgIContainer> image;
aRequest->GetImage(getter_AddRefs(image));
if (image) {
if (NS_SUCCEEDED(aRequest->GetImage(getter_AddRefs(image)))) {
// Check to verify that the image is animated. If so, then add it to the
// list of images tracked by the refresh driver.
bool isAnimated = false;
@ -4825,8 +4823,7 @@ nsLayoutUtils::DeregisterImageRequest(nsPresContext* aPresContext,
if (aRequest) {
nsCOMPtr<imgIContainer> image;
aRequest->GetImage(getter_AddRefs(image));
if (image) {
if (NS_SUCCEEDED(aRequest->GetImage(getter_AddRefs(image)))) {
aPresContext->RefreshDriver()->RemoveImageRequest(aRequest);
if (aRequestRegistered) {

View File

@ -464,8 +464,7 @@ nsRefreshDriver::ImageRequestEnumerator(nsISupportsHashKey* aEntry,
imgIRequest* req = static_cast<imgIRequest*>(aEntry->GetKey());
NS_ABORT_IF_FALSE(req, "Unable to retrieve the image request");
nsCOMPtr<imgIContainer> image;
req->GetImage(getter_AddRefs(image));
if (image) {
if (NS_SUCCEEDED(req->GetImage(getter_AddRefs(image)))) {
image->RequestRefresh(mostRecentRefresh);
}