在大端机器(solaris-sparc,hpux-hppa)上从奇数内存地址取一个整形(2 or 4 bytes)会崩溃。如:

unsigned short Res = *(unsigned short *) tmpArray;

应该:

char tmpArray[sizeof(unsigned short)] = {0};
for(int i = 0; i < sizeof(unsigned short); ++i)
{
tmpArray[i] = *(pcNewHdr + i);
}

unsigned short Res =*(unsigned short *) tmpArray;

05-02 14:07