Commit bfed6e5f authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

windowscodecs: Add NULL pointer checks to some color context methods.

parent b9ead1a7
...@@ -144,6 +144,8 @@ static HRESULT WINAPI ColorContext_GetType(IWICColorContext *iface, ...@@ -144,6 +144,8 @@ static HRESULT WINAPI ColorContext_GetType(IWICColorContext *iface,
ColorContext *This = impl_from_IWICColorContext(iface); ColorContext *This = impl_from_IWICColorContext(iface);
TRACE("(%p,%p)\n", iface, pType); TRACE("(%p,%p)\n", iface, pType);
if (!pType) return E_INVALIDARG;
*pType = This->type; *pType = This->type;
return S_OK; return S_OK;
} }
...@@ -157,6 +159,8 @@ static HRESULT WINAPI ColorContext_GetProfileBytes(IWICColorContext *iface, ...@@ -157,6 +159,8 @@ static HRESULT WINAPI ColorContext_GetProfileBytes(IWICColorContext *iface,
if (This->type != WICColorContextProfile) if (This->type != WICColorContextProfile)
return WINCODEC_ERR_NOTINITIALIZED; return WINCODEC_ERR_NOTINITIALIZED;
if (!pcbActual) return E_INVALIDARG;
if (cbBuffer >= This->profile_len && pbBuffer) if (cbBuffer >= This->profile_len && pbBuffer)
memcpy(pbBuffer, This->profile, This->profile_len); memcpy(pbBuffer, This->profile, This->profile_len);
...@@ -171,6 +175,8 @@ static HRESULT WINAPI ColorContext_GetExifColorSpace(IWICColorContext *iface, ...@@ -171,6 +175,8 @@ static HRESULT WINAPI ColorContext_GetExifColorSpace(IWICColorContext *iface,
ColorContext *This = impl_from_IWICColorContext(iface); ColorContext *This = impl_from_IWICColorContext(iface);
TRACE("(%p,%p)\n", iface, pValue); TRACE("(%p,%p)\n", iface, pValue);
if (!pValue) return E_INVALIDARG;
*pValue = This->exif_color_space; *pValue = This->exif_color_space;
return S_OK; return S_OK;
} }
...@@ -191,6 +197,8 @@ HRESULT ColorContext_Create(IWICColorContext **colorcontext) ...@@ -191,6 +197,8 @@ HRESULT ColorContext_Create(IWICColorContext **colorcontext)
{ {
ColorContext *This; ColorContext *This;
if (!colorcontext) return E_INVALIDARG;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(ColorContext)); This = HeapAlloc(GetProcessHeap(), 0, sizeof(ColorContext));
if (!This) return E_OUTOFMEMORY; if (!This) return E_OUTOFMEMORY;
......
...@@ -854,6 +854,8 @@ static HRESULT WINAPI PngDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *i ...@@ -854,6 +854,8 @@ static HRESULT WINAPI PngDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *i
TRACE("(%p,%u,%p,%p)\n", iface, cCount, ppIColorContexts, pcActualCount); TRACE("(%p,%u,%p,%p)\n", iface, cCount, ppIColorContexts, pcActualCount);
if (!pcActualCount) return E_INVALIDARG;
EnterCriticalSection(&This->lock); EnterCriticalSection(&This->lock);
if (ppng_get_iCCP(This->png_ptr, This->info_ptr, &name, &compression_type, &profile, &len)) 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) ...@@ -331,6 +331,9 @@ static void test_color_contexts(void)
ok(decoder != 0, "Failed to load PNG image data\n"); ok(decoder != 0, "Failed to load PNG image data\n");
/* global color context */ /* global color context */
hr = IWICBitmapDecoder_GetColorContexts(decoder, 0, NULL, NULL);
ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "GetColorContexts error %#x\n", hr);
count = 0xdeadbeef; count = 0xdeadbeef;
hr = IWICBitmapDecoder_GetColorContexts(decoder, 0, NULL, &count); hr = IWICBitmapDecoder_GetColorContexts(decoder, 0, NULL, &count);
ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "GetColorContexts error %#x\n", hr); ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "GetColorContexts error %#x\n", hr);
...@@ -340,6 +343,9 @@ static void test_color_contexts(void) ...@@ -340,6 +343,9 @@ static void test_color_contexts(void)
hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
ok(hr == S_OK, "GetFrame error %#x\n", hr); 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; count = 0xdeadbeef;
hr = IWICBitmapFrameDecode_GetColorContexts(frame, 0, NULL, &count); hr = IWICBitmapFrameDecode_GetColorContexts(frame, 0, NULL, &count);
ok(hr == S_OK, "GetColorContexts error %#x\n", hr); ok(hr == S_OK, "GetColorContexts error %#x\n", hr);
...@@ -366,19 +372,31 @@ static void test_color_contexts(void) ...@@ -366,19 +372,31 @@ static void test_color_contexts(void)
ok(hr == S_OK, "GetColorContexts error %#x\n", hr); ok(hr == S_OK, "GetColorContexts error %#x\n", hr);
ok(count == 1, "unexpected count %u\n", count); 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); hr = IWICImagingFactory_CreateColorContext(factory, &context);
ok(hr == S_OK, "CreateColorContext error %#x\n", hr); 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; type = 0xdeadbeef;
hr = IWICColorContext_GetType(context, &type); hr = IWICColorContext_GetType(context, &type);
ok(hr == S_OK, "GetType error %#x\n", hr); ok(hr == S_OK, "GetType error %#x\n", hr);
ok(type == WICColorContextUninitialized, "unexpected type %u\n", type); 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; size = 0;
hr = IWICColorContext_GetProfileBytes(context, 0, NULL, &size); hr = IWICColorContext_GetProfileBytes(context, 0, NULL, &size);
ok(hr == WINCODEC_ERR_NOTINITIALIZED, "GetProfileBytes error %#x\n", hr); ok(hr == WINCODEC_ERR_NOTINITIALIZED, "GetProfileBytes error %#x\n", hr);
ok(!size, "unexpected size %u\n", size); 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; colorspace = 0xdeadbeef;
hr = IWICColorContext_GetExifColorSpace(context, &colorspace); hr = IWICColorContext_GetExifColorSpace(context, &colorspace);
ok(hr == S_OK, "GetExifColorSpace error %#x\n", hr); ok(hr == S_OK, "GetExifColorSpace error %#x\n", hr);
...@@ -424,6 +442,9 @@ static void test_color_contexts(void) ...@@ -424,6 +442,9 @@ static void test_color_contexts(void)
hr = IWICBitmapFrameDecode_GetColorContexts(frame, count, &context, &count); hr = IWICBitmapFrameDecode_GetColorContexts(frame, count, &context, &count);
ok(hr == S_OK, "GetColorContexts error %#x\n", hr); 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; size = 0;
hr = IWICColorContext_GetProfileBytes(context, 0, NULL, &size); hr = IWICColorContext_GetProfileBytes(context, 0, NULL, &size);
ok(hr == S_OK, "GetProfileBytes error %#x\n", hr); ok(hr == S_OK, "GetProfileBytes error %#x\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment