Bug 642902 - If a profile's invalid, we leak it. Don't. r=jrmuizel

This commit is contained in:
Joe Drew 2011-03-23 12:20:43 -04:00
Родитель c1d15cca8e
Коммит 8ff517c46c
1 изменённых файлов: 16 добавлений и 8 удалений

Просмотреть файл

@ -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;