diff options
-rw-r--r-- | Projects/VC2022/testbed/testbed.vcxproj | 2 | ||||
-rw-r--r-- | testbed/testcms2.c | 41 | ||||
-rwxr-xr-x | testbed/testcms2.h | 4 | ||||
-rwxr-xr-x | testbed/testplugin.c | 1 |
4 files changed, 29 insertions, 19 deletions
diff --git a/Projects/VC2022/testbed/testbed.vcxproj b/Projects/VC2022/testbed/testbed.vcxproj index 85388a2..4015599 100644 --- a/Projects/VC2022/testbed/testbed.vcxproj +++ b/Projects/VC2022/testbed/testbed.vcxproj @@ -55,6 +55,7 @@ <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v143</PlatformToolset> + <EnableASAN>true</EnableASAN> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> @@ -65,6 +66,7 @@ <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v143</PlatformToolset> + <EnableASAN>true</EnableASAN> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/testbed/testcms2.c b/testbed/testcms2.c index 1bd0dd8..a733e7e 100644 --- a/testbed/testcms2.c +++ b/testbed/testcms2.c @@ -56,6 +56,15 @@ void Die(const char* Reason, ...) exit(1); } +static +void* chknull(void* mem) +{ + if (mem == NULL) + Die("Memory may be corrupted"); + + return mem; +} + // Memory management replacement ----------------------------------------------------------------------------- @@ -115,7 +124,7 @@ void* DebugMalloc(cmsContext ContextID, cmsUInt32Number size) if (size > SingleHit) SingleHit = size; - blk = (_cmsMemoryBlock*) malloc(size + SIZE_OF_MEM_HEADER); + blk = (_cmsMemoryBlock*) chknull(malloc(size + SIZE_OF_MEM_HEADER)); if (blk == NULL) return NULL; blk ->KeepSize = size; @@ -1019,7 +1028,7 @@ cmsInt32Number Check1D(cmsInt32Number nNodesToCheck, cmsBool Down, cmsInt32Numb cmsInterpParams* p; cmsUInt16Number* Tab; - Tab = (cmsUInt16Number*) malloc(sizeof(cmsUInt16Number)* nNodesToCheck); + Tab = (cmsUInt16Number*) chknull(malloc(sizeof(cmsUInt16Number)* nNodesToCheck)); if (Tab == NULL) return 0; p = _cmsComputeInterpParams(DbgThread(), nNodesToCheck, 1, 1, Tab, CMS_LERP_FLAGS_16BITS); @@ -5294,7 +5303,7 @@ cmsInt32Number CheckRAWtags(cmsInt32Number Pass, cmsHPROFILE hProfile) case 2: if (!cmsReadRawTag(hProfile, (cmsTagSignature) 0x31323334, Buffer, 7)) return 0; - if (strncmp(Buffer, "data123", 7) != 0) return 0; + if (memcmp(Buffer, "data123", 7) != 0) return 0; return 1; default: @@ -7849,7 +7858,7 @@ cmsInt32Number CheckMeta(void) rc = cmsSaveProfileToMem(p, NULL, &clen); if (!rc) return 0; - data = (char*) malloc(clen); + data = (char*) chknull(malloc(clen)); rc = cmsSaveProfileToMem(p, data, &clen); if (!rc) return 0; @@ -8302,9 +8311,9 @@ int Check_sRGB_Rountrips(void) for (g = 0; g <= 255; g += 16) for (b = 0; b <= 255; b += 16) { - seed[0] = rgb[0] = ((r << 8) | r); - seed[1] = rgb[1] = ((g << 8) | g); - seed[2] = rgb[2] = ((b << 8) | b); + seed[0] = rgb[0] = (cmsUInt16Number) ((r << 8) | r); + seed[1] = rgb[1] = (cmsUInt16Number) ((g << 8) | g); + seed[2] = rgb[2] = (cmsUInt16Number) ((b << 8) | b); for (i = 0; i < 50; i++) { @@ -8516,7 +8525,7 @@ void SpeedTest32bits(const char * Title, cmsHPROFILE hlcmsProfileIn, cmsHPROFILE NumPixels = 256 / Interval * 256 / Interval * 256 / Interval; Mb = NumPixels * sizeof(Scanline_rgba32); - In = (Scanline_rgba32 *) malloc(Mb); + In = (Scanline_rgba32 *) chknull(malloc(Mb)); j = 0; for (r=0; r < 256; r += Interval) @@ -8567,7 +8576,7 @@ void SpeedTest16bits(const char * Title, cmsHPROFILE hlcmsProfileIn, cmsHPROFILE Mb = 256*256*256 * sizeof(Scanline_rgb16); - In = (Scanline_rgb16*) malloc(Mb); + In = (Scanline_rgb16*) chknull(malloc(Mb)); j = 0; for (r=0; r < 256; r++) @@ -8620,7 +8629,7 @@ void SpeedTest32bitsCMYK(const char * Title, cmsHPROFILE hlcmsProfileIn, cmsHPRO NumPixels = 256 / Interval * 256 / Interval * 256 / Interval; Mb = NumPixels * sizeof(Scanline_rgba32); - In = (Scanline_rgba32 *) malloc(Mb); + In = (Scanline_rgba32 *) chknull(malloc(Mb)); j = 0; for (r=0; r < 256; r += Interval) @@ -8673,7 +8682,7 @@ void SpeedTest16bitsCMYK(const char * Title, cmsHPROFILE hlcmsProfileIn, cmsHPRO Mb = 256*256*256*sizeof(Scanline_rgba16); - In = (Scanline_rgba16*) malloc(Mb); + In = (Scanline_rgba16*) chknull(malloc(Mb)); j = 0; for (r=0; r < 256; r++) @@ -8726,7 +8735,7 @@ void SpeedTest8bits(const char * Title, cmsHPROFILE hlcmsProfileIn, cmsHPROFILE Mb = 256*256*256*sizeof(Scanline_rgb8); - In = (Scanline_rgb8*) malloc(Mb); + In = (Scanline_rgb8*) chknull(malloc(Mb)); j = 0; for (r=0; r < 256; r++) @@ -8777,7 +8786,7 @@ void SpeedTest8bitsCMYK(const char * Title, cmsHPROFILE hlcmsProfileIn, cmsHPROF Mb = 256*256*256*sizeof(Scanline_rgba8); - In = (Scanline_rgba8*) malloc(Mb); + In = (Scanline_rgba8*) chknull(malloc(Mb)); j = 0; for (r=0; r < 256; r++) @@ -8833,7 +8842,7 @@ void SpeedTest32bitsGray(const char * Title, cmsHPROFILE hlcmsProfileIn, cmsHPRO NumPixels = 256 / Interval * 256 / Interval * 256 / Interval; Mb = NumPixels * sizeof(cmsFloat32Number); - In = (cmsFloat32Number*) malloc(Mb); + In = (cmsFloat32Number*) chknull(malloc(Mb)); j = 0; for (r = 0; r < 256; r += Interval) @@ -8878,7 +8887,7 @@ void SpeedTest16bitsGray(const char * Title, cmsHPROFILE hlcmsProfileIn, cmsHPRO cmsCloseProfile(hlcmsProfileOut); Mb = 256*256*256 * sizeof(cmsUInt16Number); - In = (cmsUInt16Number *) malloc(Mb); + In = (cmsUInt16Number *) chknull(malloc(Mb)); j = 0; for (r=0; r < 256; r++) @@ -8924,7 +8933,7 @@ void SpeedTest8bitsGray(const char * Title, cmsHPROFILE hlcmsProfileIn, cmsHPROF cmsCloseProfile(hlcmsProfileOut); Mb = 256*256*256; - In = (cmsUInt8Number*) malloc(Mb); + In = (cmsUInt8Number*) chknull(malloc(Mb)); j = 0; for (r=0; r < 256; r++) diff --git a/testbed/testcms2.h b/testbed/testcms2.h index 306934e..bf76e0c 100755 --- a/testbed/testcms2.h +++ b/testbed/testcms2.h @@ -41,10 +41,10 @@ #ifdef CMS_IS_WINDOWS_ # include <io.h> # include <direct.h> -# define CHDIR(a) _chdir(a) +# define CHDIR(a) (void)_chdir(a) #else # include <unistd.h> -# define CHDIR(a) chdir(a) +# define CHDIR(a) (void)chdir(a) #endif #define cmsmin(a, b) (((a) < (b)) ? (a) : (b)) diff --git a/testbed/testplugin.c b/testbed/testplugin.c index 6c9aee7..cb25108 100755 --- a/testbed/testplugin.c +++ b/testbed/testplugin.c @@ -979,7 +979,6 @@ cmsInt32Number CheckMPEPlugin(void) cmsContext cpy = NULL; cmsContext cpy2 = NULL; cmsHPROFILE h = NULL; - cmsUInt32Number myTag = 1234; cmsUInt32Number rc = 0; char* data = NULL; cmsUInt32Number clen = 0; |