1.1 --- a/src/share/native/sun/java2d/cmm/lcms/LCMS.c Thu May 21 16:29:58 2009 +0100
1.2 +++ b/src/share/native/sun/java2d/cmm/lcms/LCMS.c Thu May 21 18:41:50 2009 +0100
1.3 @@ -610,14 +610,19 @@
1.4 return FALSE;
1.5 }
1.6
1.7 - if (!Icc->Grow(Icc, delta)) {
1.8 - free(ptr);
1.9 - if(isNew) {
1.10 - Icc->TagCount--;
1.11 + /* We change the size of Icc here only if we know it'll actually
1.12 + * grow: if Icc is about to shrink we must wait until we've read
1.13 + * the previous data. */
1.14 + if (delta > 0) {
1.15 + if (!Icc->Grow(Icc, delta)) {
1.16 + free(ptr);
1.17 + if(isNew) {
1.18 + Icc->TagCount--;
1.19 + }
1.20 + J2dRlsTraceLn(J2D_TRACE_ERROR,
1.21 + "_cmsModifyTagData: Icc->Grow() == FALSE");
1.22 + return FALSE;
1.23 }
1.24 - J2dRlsTraceLn(J2D_TRACE_ERROR,
1.25 - "_cmsModifyTagData: Icc->Grow() == FALSE");
1.26 - return FALSE;
1.27 }
1.28
1.29 /* Compute size of tag data before/after the modified tag */
1.30 @@ -680,6 +685,18 @@
1.31 temp = TransportValue32(profileSize);
1.32 Icc->Write(Icc, sizeof(icUInt32Number), &temp);
1.33
1.34 + /* Shrink Icc, if needed. */
1.35 + if (delta < 0) {
1.36 + if (!Icc->Grow(Icc, delta)) {
1.37 + free(ptr);
1.38 + if(isNew) {
1.39 + Icc->TagCount--;
1.40 + }
1.41 + J2dRlsTraceLn(J2D_TRACE_ERROR,
1.42 + "_cmsModifyTagData: Icc->Grow() == FALSE");
1.43 + return FALSE;
1.44 + }
1.45 + }
1.46
1.47 /* Adjust tag offsets: if the tag is new, we must account
1.48 for the new tag table entry; otherwise, only those tags after