windowscodecs: Add NULL pointer checks to some color context methods.
This commit is contained in:
parent
b9ead1a7ea
commit
bfed6e5f30
|
@ -144,6 +144,8 @@ static HRESULT WINAPI ColorContext_GetType(IWICColorContext *iface,
|
|||
ColorContext *This = impl_from_IWICColorContext(iface);
|
||||
TRACE("(%p,%p)\n", iface, pType);
|
||||
|
||||
if (!pType) return E_INVALIDARG;
|
||||
|
||||
*pType = This->type;
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -157,6 +159,8 @@ static HRESULT WINAPI ColorContext_GetProfileBytes(IWICColorContext *iface,
|
|||
if (This->type != WICColorContextProfile)
|
||||
return WINCODEC_ERR_NOTINITIALIZED;
|
||||
|
||||
if (!pcbActual) return E_INVALIDARG;
|
||||
|
||||
if (cbBuffer >= This->profile_len && pbBuffer)
|
||||
memcpy(pbBuffer, This->profile, This->profile_len);
|
||||
|
||||
|
@ -171,6 +175,8 @@ static HRESULT WINAPI ColorContext_GetExifColorSpace(IWICColorContext *iface,
|
|||
ColorContext *This = impl_from_IWICColorContext(iface);
|
||||
TRACE("(%p,%p)\n", iface, pValue);
|
||||
|
||||
if (!pValue) return E_INVALIDARG;
|
||||
|
||||
*pValue = This->exif_color_space;
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -191,6 +197,8 @@ HRESULT ColorContext_Create(IWICColorContext **colorcontext)
|
|||
{
|
||||
ColorContext *This;
|
||||
|
||||
if (!colorcontext) return E_INVALIDARG;
|
||||
|
||||
This = HeapAlloc(GetProcessHeap(), 0, sizeof(ColorContext));
|
||||
if (!This) return E_OUTOFMEMORY;
|
||||
|
||||
|
|
|
@ -854,6 +854,8 @@ static HRESULT WINAPI PngDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *i
|
|||
|
||||
TRACE("(%p,%u,%p,%p)\n", iface, cCount, ppIColorContexts, pcActualCount);
|
||||
|
||||
if (!pcActualCount) return E_INVALIDARG;
|
||||
|
||||
EnterCriticalSection(&This->lock);
|
||||
|
||||
if (ppng_get_iCCP(This->png_ptr, This->info_ptr, &name, &compression_type, &profile, &len))
|
||||
|
|
|
@ -331,6 +331,9 @@ static void test_color_contexts(void)
|
|||
ok(decoder != 0, "Failed to load PNG image data\n");
|
||||
|
||||
/* global color context */
|
||||
hr = IWICBitmapDecoder_GetColorContexts(decoder, 0, NULL, NULL);
|
||||
ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "GetColorContexts error %#x\n", hr);
|
||||
|
||||
count = 0xdeadbeef;
|
||||
hr = IWICBitmapDecoder_GetColorContexts(decoder, 0, NULL, &count);
|
||||
ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "GetColorContexts error %#x\n", hr);
|
||||
|
@ -340,6 +343,9 @@ static void test_color_contexts(void)
|
|||
hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
|
||||
ok(hr == S_OK, "GetFrame error %#x\n", hr);
|
||||
|
||||
hr = IWICBitmapFrameDecode_GetColorContexts(frame, 0, NULL, NULL);
|
||||
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
|
||||
|
||||
count = 0xdeadbeef;
|
||||
hr = IWICBitmapFrameDecode_GetColorContexts(frame, 0, NULL, &count);
|
||||
ok(hr == S_OK, "GetColorContexts error %#x\n", hr);
|
||||
|
@ -366,19 +372,31 @@ static void test_color_contexts(void)
|
|||
ok(hr == S_OK, "GetColorContexts error %#x\n", hr);
|
||||
ok(count == 1, "unexpected count %u\n", count);
|
||||
|
||||
hr = IWICImagingFactory_CreateColorContext(factory, NULL);
|
||||
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
|
||||
|
||||
hr = IWICImagingFactory_CreateColorContext(factory, &context);
|
||||
ok(hr == S_OK, "CreateColorContext error %#x\n", hr);
|
||||
|
||||
hr = IWICColorContext_GetType(context, NULL);
|
||||
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
|
||||
|
||||
type = 0xdeadbeef;
|
||||
hr = IWICColorContext_GetType(context, &type);
|
||||
ok(hr == S_OK, "GetType error %#x\n", hr);
|
||||
ok(type == WICColorContextUninitialized, "unexpected type %u\n", type);
|
||||
|
||||
hr = IWICColorContext_GetProfileBytes(context, 0, NULL, NULL);
|
||||
ok(hr == WINCODEC_ERR_NOTINITIALIZED, "GetProfileBytes error %#x\n", hr);
|
||||
|
||||
size = 0;
|
||||
hr = IWICColorContext_GetProfileBytes(context, 0, NULL, &size);
|
||||
ok(hr == WINCODEC_ERR_NOTINITIALIZED, "GetProfileBytes error %#x\n", hr);
|
||||
ok(!size, "unexpected size %u\n", size);
|
||||
|
||||
hr = IWICColorContext_GetExifColorSpace(context, NULL);
|
||||
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
|
||||
|
||||
colorspace = 0xdeadbeef;
|
||||
hr = IWICColorContext_GetExifColorSpace(context, &colorspace);
|
||||
ok(hr == S_OK, "GetExifColorSpace error %#x\n", hr);
|
||||
|
@ -424,6 +442,9 @@ static void test_color_contexts(void)
|
|||
hr = IWICBitmapFrameDecode_GetColorContexts(frame, count, &context, &count);
|
||||
ok(hr == S_OK, "GetColorContexts error %#x\n", hr);
|
||||
|
||||
hr = IWICColorContext_GetProfileBytes(context, 0, NULL, NULL);
|
||||
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
|
||||
|
||||
size = 0;
|
||||
hr = IWICColorContext_GetProfileBytes(context, 0, NULL, &size);
|
||||
ok(hr == S_OK, "GetProfileBytes error %#x\n", hr);
|
||||
|
|
Loading…
Reference in New Issue