Bug 1166082: Check if the lock succeeded before using it. r=bschouten

This commit is contained in:
Milan Sreckovic 2015-05-20 14:14:49 -04:00
parent f8a6b0ef50
commit 9522fd7efe
2 changed files with 14 additions and 5 deletions

View File

@ -746,7 +746,11 @@ CompositorD3D9::PaintToTarget()
device()->GetRenderTargetData(backBuff, destSurf);
D3DLOCKED_RECT rect;
destSurf->LockRect(&rect, nullptr, D3DLOCK_READONLY);
HRESULT hr = destSurf->LockRect(&rect, nullptr, D3DLOCK_READONLY);
if (FAILED(hr) || !rect.pBits) {
gfxCriticalError() << "Failed to lock rect in paint to target D3D9 " << hexa(hr);
return;
}
RefPtr<DataSourceSurface> sourceSurface =
Factory::CreateWrappingDataSourceSurface((uint8_t*)rect.pBits,
rect.Pitch,

View File

@ -192,9 +192,10 @@ TextureSourceD3D9::InitTextures(DeviceManagerD3D9* aDeviceManager,
}
tmpTexture->GetSurfaceLevel(0, byRef(aSurface));
aSurface->LockRect(&aLockedRect, nullptr, 0);
if (!aLockedRect.pBits) {
NS_WARNING("Could not lock surface");
HRESULT hr = aSurface->LockRect(&aLockedRect, nullptr, 0);
if (FAILED(hr) || !aLockedRect.pBits) {
gfxCriticalError() << "Failed to lock rect initialize texture in D3D9 " << hexa(hr);
return nullptr;
}
@ -707,7 +708,11 @@ CairoTextureClientD3D9::BorrowDrawTarget()
// windows surface optimization.
// Instead we have to use a gfxImageSurface and fallback for font drawing.
D3DLOCKED_RECT rect;
mD3D9Surface->LockRect(&rect, nullptr, 0);
HRESULT hr = mD3D9Surface->LockRect(&rect, nullptr, 0);
if (FAILED(hr) || !rect.pBits) {
gfxCriticalError() << "Failed to lock rect borrowing the target in D3D9 " << hexa(hr);
return nullptr;
}
mSurface = new gfxImageSurface((uint8_t*)rect.pBits, mSize,
rect.Pitch, SurfaceFormatToImageFormat(mFormat));
mLockRect = true;