windowscodecs: Return fail for unsupported format in DdsDecoder_Initialize().

Signed-off-by: Ziqing Hui <zhui@codeweavers.com>
Signed-off-by: Esme Povirk <esme@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ziqing Hui 2020-07-15 22:01:14 +08:00 committed by Alexandre Julliard
parent 81405aa86d
commit f98a32ad47
2 changed files with 17 additions and 4 deletions

View file

@ -626,10 +626,26 @@ static HRESULT WINAPI DdsDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
WICDecodeOptions cacheOptions)
{
DdsDecoder *This = impl_from_IWICBitmapDecoder(iface);
HRESULT hr;
TRACE("(%p,%p,%x)\n", iface, pIStream, cacheOptions);
return IWICWineDecoder_Initialize(&This->IWICWineDecoder_iface, pIStream, cacheOptions);
EnterCriticalSection(&This->lock);
hr = IWICWineDecoder_Initialize(&This->IWICWineDecoder_iface, pIStream, cacheOptions);
if (FAILED(hr)) goto end;
if (!This->info.compressed || This->info.dimension == WICDdsTextureCube) {
IStream_Release(pIStream);
This->stream = NULL;
This->initialized = FALSE;
hr = WINCODEC_ERR_BADHEADER;
}
end:
LeaveCriticalSection(&This->lock);
return hr;
}
static HRESULT WINAPI DdsDecoder_GetContainerFormat(IWICBitmapDecoder *iface,

View file

@ -237,7 +237,6 @@ static HRESULT init_decoder(IWICBitmapDecoder *decoder, IWICStream *stream, HRES
if (index == -1) {
ok(hr == S_OK, "Decoder initialize failed, hr %#x\n", hr);
} else {
todo_wine_if(wine_init)
ok(hr == expected, "Test %u: Expected hr %#x, got %#x\n", index, expected, hr);
}
@ -251,10 +250,8 @@ static HRESULT init_decoder(IWICBitmapDecoder *decoder, IWICStream *stream, HRES
if (hr == S_OK) {
hr = IWICWineDecoder_Initialize(wine_decoder, (IStream*)stream, WICDecodeMetadataCacheOnDemand);
if (index == -1) {
todo_wine
ok(hr == S_OK, "Initialize failed, hr %#x\n", hr);
} else {
todo_wine
ok(hr == S_OK, "Test %u: Initialize failed, hr %#x\n", index, hr);
}