Hi Marti,
It seems to be a problem in the function _cmsSaveProfileToMem. After saving profile into memory, the profile handle would be changed. I got the segmentation fault, If I use it after saving.
After the debug I found the cause. Two new line shoulb be added in this function to avoid the profile handle change.
BOOL LCMSEXPORT _cmsSaveProfileToMem(cmsHPROFILE hProfile, void *MemPtr,
size_t* BytesNeeded)
{
LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
LCMSICCPROFILE Keep;
CopyMemory(&Keep, Icc, sizeof(LCMSICCPROFILE));
_cmsSetSaveToMemory(Icc, NULL, 0);
// Pass #1 does compute offsets
if (!SaveHeader(Icc)) return FALSE;
if (!SaveTagDirectory(Icc)) return FALSE;
if (!SaveTags(Icc)) return FALSE;
if (!MemPtr) {
// update BytesSaved so caller knows how many bytes are needed for MemPtr
*BytesNeeded = Icc ->UsedSpace;
CopyMemory(Icc, &Keep, sizeof(LCMSICCPROFILE)); --> add this line
return TRUE;
}
if (*BytesNeeded < Icc ->UsedSpace) {
// need at least UsedSpace in MemPtr to continue
CopyMemory(Icc, &Keep, sizeof(LCMSICCPROFILE)); --> add this line
return FALSE;
}
_cmsSetSaveToMemory(Icc, MemPtr, *BytesNeeded);
// Pass #2 does save to file into supplied stream
if (!SaveHeader(Icc)) goto CleanUp;
if (!SaveTagDirectory(Icc)) goto CleanUp;
if (!SaveTags(Icc)) goto CleanUp;
// update BytesSaved so caller knows how many bytes put into stream
*BytesNeeded = Icc ->UsedSpace;
Icc ->Close(Icc);
CopyMemory(Icc, &Keep, sizeof(LCMSICCPROFILE));
return TRUE;
CleanUp:
Icc ->Close(Icc);
CopyMemory(Icc, &Keep, sizeof(LCMSICCPROFILE));
return FALSE;
}
Mit freundlichen Grüßen
Wei Wang
(Development)
----------------------------------------------------
Compart Systemhaus GmbH
Otto-Lilienthal-Str. 38
71034 Böblingen
Tel: +49 7031 6205-457
Fax: +49 7031 6205-555
mailto:[EMAIL PROTECTED]
http://www.compart.net
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Lcms-user mailing list Lcms-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lcms-user