diff --git a/modules/libpr0n/decoders/nsJPEGDecoder.cpp b/modules/libpr0n/decoders/nsJPEGDecoder.cpp index a31f7f31eb7..762f46de518 100644 --- a/modules/libpr0n/decoders/nsJPEGDecoder.cpp +++ b/modules/libpr0n/decoders/nsJPEGDecoder.cpp @@ -84,6 +84,20 @@ static PRLogModuleInfo *gJPEGDecoderAccountingLog = PR_NewLogModule("JPEGDecoder #define gJPEGDecoderAccountingLog #endif +static qcms_profile* +GetICCProfile(struct jpeg_decompress_struct &info) +{ + JOCTET* profilebuf; + PRUint32 profileLength; + qcms_profile* profile = nsnull; + + if (read_icc_profile(&info, &profilebuf, &profileLength)) { + profile = qcms_profile_from_memory(profile, profileLength); + free(profilebuf); + } + + return profile; +} METHODDEF(void) init_source (j_decompress_ptr jd); METHODDEF(boolean) fill_input_buffer (j_decompress_ptr jd); @@ -248,14 +262,8 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) return; /* We're doing a full decode. */ - JOCTET *profile; - PRUint32 profileLength; - - if ((mCMSMode != eCMSMode_Off) && - read_icc_profile(&mInfo, &profile, &profileLength) && - (mInProfile = qcms_profile_from_memory(profile, profileLength)) != NULL) { - free(profile); - + if (mCMSMode != eCMSMode_Off && + (mInProfile = GetICCProfile(mInfo)) != nsnull) { PRUint32 profileSpace = qcms_profile_get_color_space(mInProfile); PRBool mismatch = PR_FALSE;