Skip to content

Commit

Permalink
fix for big endian MLU bug
Browse files Browse the repository at this point in the history
Thanks to Sergei Trofimovic for the fix
  • Loading branch information
mm2 committed Nov 20, 2017
1 parent 7e8fd03 commit 8aca404
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -37,6 +37,7 @@ John Hein
Thomas Weber (Debian)
Mark Allen
Noel Carboni
Sergei Trofimovic

Special Thanks
--------------
Expand Down
20 changes: 6 additions & 14 deletions src/cmsnamed.c
Expand Up @@ -183,27 +183,19 @@ cmsBool AddMLUBlock(cmsMLU* mlu, cmsUInt32Number size, const wchar_t *Block,

static
cmsUInt16Number strTo16(const char str[3])
{
{
const cmsUInt8Number* ptr8 = (const cmsUInt8Number*)str;
cmsUInt16Number n = (cmsUInt16Number) (((cmsUInt16Number) ptr8[1] << 8) | ptr8[0]);
cmsUInt16Number n = (cmsUInt16Number)(((cmsUInt16Number)ptr8[0] << 8) | ptr8[1]);

return _cmsAdjustEndianess16(n);
return n;
}

static
void strFrom16(char str[3], cmsUInt16Number n)
{
// Assuming this would be aligned
union {

cmsUInt16Number n;
cmsUInt8Number str[2];

} c;

c.n = _cmsAdjustEndianess16(n);

str[0] = (char) c.str[0]; str[1] = (char) c.str[1]; str[2] = (char) 0;
str[0] = (char)(n >> 8);
str[1] = (char)n;
str[2] = (char)0;

}

Expand Down

0 comments on commit 8aca404

Please sign in to comment.