Hans Leidekker : mscms: Check the return value of a couple of liblcms2 calls.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Aug 6 10:15:44 CDT 2015
Module: wine
Branch: master
Commit: ee849808957773e8ad8b21c86b1f4b347b2f0cbf
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ee849808957773e8ad8b21c86b1f4b347b2f0cbf
Author: Hans Leidekker <hans at codeweavers.com>
Date: Thu Aug 6 14:46:15 2015 +0200
mscms: Check the return value of a couple of liblcms2 calls.
---
dlls/mscms/profile.c | 15 ++++++++++++---
dlls/mscms/transform.c | 22 ++++++++++++++++++----
2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/dlls/mscms/profile.c b/dlls/mscms/profile.c
index eb9b4d0..f0c4087 100644
--- a/dlls/mscms/profile.c
+++ b/dlls/mscms/profile.c
@@ -1152,7 +1152,7 @@ BOOL WINAPI IsColorProfileTagPresent( HPROFILE handle, TAGTYPE type, PBOOL prese
release_profile( profile );
return FALSE;
}
- *present = cmsIsTag( profile->cmsprofile, type );
+ *present = (cmsIsTag( profile->cmsprofile, type ) != 0);
release_profile( profile );
ret = TRUE;
@@ -1406,7 +1406,11 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
if (!(data = HeapAlloc( GetProcessHeap(), 0, profile->cbDataSize ))) return NULL;
memcpy( data, profile->pProfileData, profile->cbDataSize );
- cmsprofile = cmsOpenProfileFromMem( data, profile->cbDataSize );
+ if (!(cmsprofile = cmsOpenProfileFromMem( data, profile->cbDataSize )))
+ {
+ HeapFree( GetProcessHeap(), 0, data );
+ return FALSE;
+ }
size = profile->cbDataSize;
}
else if (profile->dwType == PROFILE_FILENAME)
@@ -1464,7 +1468,12 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
HeapFree( GetProcessHeap(), 0, data );
return NULL;
}
- cmsprofile = cmsOpenProfileFromMem( data, size );
+ if (!(cmsprofile = cmsOpenProfileFromMem( data, size )))
+ {
+ CloseHandle( handle );
+ HeapFree( GetProcessHeap(), 0, data );
+ return NULL;
+ }
}
else
{
diff --git a/dlls/mscms/transform.c b/dlls/mscms/transform.c
index aed7011..058cffa 100644
--- a/dlls/mscms/transform.c
+++ b/dlls/mscms/transform.c
@@ -175,6 +175,12 @@ HTRANSFORM WINAPI CreateColorTransformW( LPLOGCOLORSPACEW space, HPROFILE dest,
cmsoutput = dst->cmsprofile;
transform.cmstransform = cmsCreateProofingTransform(cmsinput, in_format, cmsoutput, out_format, cmstarget,
intent, INTENT_ABSOLUTE_COLORIMETRIC, proofing);
+ if (!transform.cmstransform)
+ {
+ if (tgt) release_profile( tgt );
+ release_profile( dst );
+ return FALSE;
+ }
ret = create_transform( &transform );
@@ -254,9 +260,15 @@ HTRANSFORM WINAPI CreateMultiProfileTransform( PHPROFILE profiles, DWORD nprofil
{
cmsprofiles[1] = profile1->cmsprofile;
}
- transform.cmstransform = cmsCreateMultiprofileTransform( cmsprofiles, nprofiles, in_format, out_format, *intents, 0 );
-
+ transform.cmstransform = cmsCreateMultiprofileTransform( cmsprofiles, nprofiles, in_format,
+ out_format, *intents, 0 );
HeapFree( GetProcessHeap(), 0, cmsprofiles );
+ if (!transform.cmstransform)
+ {
+ release_profile( profile0 );
+ release_profile( profile1 );
+ return FALSE;
+ }
ret = create_transform( &transform );
}
@@ -327,7 +339,8 @@ BOOL WINAPI TranslateBitmapBits( HTRANSFORM handle, PVOID srcbits, BMFORMAT inpu
outputstride, callback, data );
if (!transform) return FALSE;
- cmsChangeBuffersFormat( transform->cmstransform, from_bmformat(input), from_bmformat(output) );
+ if (!cmsChangeBuffersFormat( transform->cmstransform, from_bmformat(input), from_bmformat(output) ))
+ return FALSE;
cmsDoTransform( transform->cmstransform, srcbits, destbits, width * height );
release_transform( transform );
@@ -368,7 +381,8 @@ BOOL WINAPI TranslateColors( HTRANSFORM handle, PCOLOR in, DWORD count,
if (!transform) return FALSE;
xfrm = transform->cmstransform;
- cmsChangeBuffersFormat( xfrm, from_type(input_type), from_type(output_type) );
+ if (!cmsChangeBuffersFormat( xfrm, from_type(input_type), from_type(output_type) ))
+ return FALSE;
switch (input_type)
{
More information about the wine-cvs
mailing list