summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2013-10-30 13:46:34 +0100
committerMarti Maria <info@littlecms.com>2013-10-30 13:46:34 +0100
commitb4f5c91a2c1582bd284f0d0f49cb43e2c2235a79 (patch)
treeb67b72c56c13c71744fa879251af3822e6b783c0
parentfda1211c344178b05b71b5c8e0b45412b49c0599 (diff)
downloadlcms2-b4f5c91a2c1582bd284f0d0f49cb43e2c2235a79.tar.gz
Fixing endianess detection and memory leaks
-rw-r--r--ChangeLog2
-rw-r--r--include/lcms2.h25
-rw-r--r--src/cmstypes.c36
-rw-r--r--src/cmsxform.c1
4 files changed, 44 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 53c0ff4..1fde607 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -130,3 +130,5 @@ Fixed a double free in recovering from a previous error in default intent handle
Fixed some indexing out of bounds in floating point interpolation
Fixed a bug in PCS/Colorspace order when reading V2 Lab devicelinks
Added a way to retrieve matrix shaper always, no matter LUT is present
+Changed endianess detection for PowerPC
+Fixed memory leaks on error handling \ No newline at end of file
diff --git a/include/lcms2.h b/include/lcms2.h
index 3297e67..c801409 100644
--- a/include/lcms2.h
+++ b/include/lcms2.h
@@ -23,7 +23,7 @@
//
//---------------------------------------------------------------------------------
//
-// Version 2.5
+// Version 2.6b
//
#ifndef _lcms2_H
@@ -72,7 +72,7 @@ extern "C" {
#endif
// Version/release
-#define LCMS_VERSION 2050
+#define LCMS_VERSION 2060
// I will give the chance of redefining basic types for compilers that are not fully C99 compliant
#ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
@@ -177,20 +177,31 @@ typedef int cmsBool;
# define CMS_USE_BIG_ENDIAN 1
#endif
-#if defined(__sgi__) || defined(__sgi) || defined(__powerpc__) || defined(sparc)
+#if defined(__sgi__) || defined(__sgi) || defined(sparc)
# define CMS_USE_BIG_ENDIAN 1
#endif
-#if defined(__ppc__) || defined(__s390__) || defined(__s390x__)
+#if defined(__s390__) || defined(__s390x__)
# define CMS_USE_BIG_ENDIAN 1
#endif
-#ifdef TARGET_CPU_PPC
-# if TARGET_CPU_PPC
+# ifdef TARGET_CPU_PPC
+# if TARGET_CPU_PPC
+# define CMS_USE_BIG_ENDIAN 1
+# endif
+# endif
+
+#if defined(__powerpc__) || defined(__ppc__) || defined(TARGET_CPU_PPC)
# define CMS_USE_BIG_ENDIAN 1
-# endif
+# if defined (__GNUC__)
+# if ( __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+# // Don't use big endian for PowerPC little endian mode
+# undef CMS_USE_BIG_ENDIAN
+# endif
+# endif
#endif
+
#ifdef macintosh
# ifdef __BIG_ENDIAN__
# define CMS_USE_BIG_ENDIAN 1
diff --git a/src/cmstypes.c b/src/cmstypes.c
index 55b1597..9114a6e 100644
--- a/src/cmstypes.c
+++ b/src/cmstypes.c
@@ -1795,9 +1795,16 @@ void *Type_LUT8_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cms
if (T == NULL) goto Error;
Temp = (cmsUInt8Number*) _cmsMalloc(self ->ContextID, nTabSize);
- if (Temp == NULL) goto Error;
+ if (Temp == NULL) {
+ _cmsFree(self ->ContextID, T);
+ goto Error;
+ }
- if (io ->Read(io, Temp, nTabSize, 1) != 1) goto Error;
+ if (io ->Read(io, Temp, nTabSize, 1) != 1) {
+ _cmsFree(self ->ContextID, T);
+ _cmsFree(self ->ContextID, Temp);
+ goto Error;
+ }
for (i = 0; i < nTabSize; i++) {
@@ -2342,27 +2349,30 @@ cmsStage* ReadCLUT(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUI
// Precision can be 1 or 2 bytes
if (Precision == 1) {
- cmsUInt8Number v;
+ cmsUInt8Number v;
for (i=0; i < Data ->nEntries; i++) {
- if (io ->Read(io, &v, sizeof(cmsUInt8Number), 1) != 1) return NULL;
- Data ->Tab.T[i] = FROM_8_TO_16(v);
+ if (io ->Read(io, &v, sizeof(cmsUInt8Number), 1) != 1) return NULL;
+ Data ->Tab.T[i] = FROM_8_TO_16(v);
}
}
else
if (Precision == 2) {
- if (!_cmsReadUInt16Array(io, Data->nEntries, Data ->Tab.T)) return NULL;
- }
- else {
- cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown precision of '%d'", Precision);
- return NULL;
- }
-
+ if (!_cmsReadUInt16Array(io, Data->nEntries, Data ->Tab.T)) {
+ cmsStageFree(CLUT);
+ return NULL;
+ }
+ }
+ else {
+ cmsStageFree(CLUT);
+ cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown precision of '%d'", Precision);
+ return NULL;
+ }
- return CLUT;
+ return CLUT;
}
static
diff --git a/src/cmsxform.c b/src/cmsxform.c
index 37a21b3..b39c116 100644
--- a/src/cmsxform.c
+++ b/src/cmsxform.c
@@ -698,6 +698,7 @@ cmsHTRANSFORM CMSEXPORT cmsCreateExtendedTransform(cmsContext ContextID,
// Check channel count
if ((cmsChannelsOf(EntryColorSpace) != cmsPipelineInputChannels(Lut)) ||
(cmsChannelsOf(ExitColorSpace) != cmsPipelineOutputChannels(Lut))) {
+ cmsPipelineFree(Lut);
cmsSignalError(ContextID, cmsERROR_NOT_SUITABLE, "Channel count doesn't match. Profile is corrupted");
return NULL;
}