c2eec1c35c11f07e831cbc66cb87e031cea458bc hiram Thu Nov 21 16:11:26 2013 -0800 correctly size 8 byte array for swapping routines refs @12209 diff --git src/lib/common.c src/lib/common.c index 19efea8..6e478c6 100644 --- src/lib/common.c +++ src/lib/common.c @@ -2831,31 +2831,31 @@ } int positiveRangeIntersection(int start1, int end1, int start2, int end2) /* Return number of bases in intersection of two ranges, or * zero if they don't intersect. */ { int ret = rangeIntersection(start1,end1,start2,end2); if (ret < 0) ret = 0; return ret; } bits64 byteSwap64(bits64 a) /* Return byte-swapped version of a */ { -union {bits64 whole; UBYTE bytes[4];} u,v; +union {bits64 whole; UBYTE bytes[8];} u,v; u.whole = a; v.bytes[0] = u.bytes[7]; v.bytes[1] = u.bytes[6]; v.bytes[2] = u.bytes[5]; v.bytes[3] = u.bytes[4]; v.bytes[4] = u.bytes[3]; v.bytes[5] = u.bytes[2]; v.bytes[6] = u.bytes[1]; v.bytes[7] = u.bytes[0]; return v.whole; } bits64 readBits64(FILE *f, boolean isSwapped) /* Read and optionally byte-swap 64 bit entity. */ { @@ -2965,31 +2965,31 @@ bits16 memReadBits16(char **pPt, boolean isSwapped) /* Read and optionally byte-swap 16 bit entity from memory buffer pointed to by * *pPt, and advance *pPt past read area. */ { bits16 val; memcpy(&val, *pPt, sizeof(val)); if (isSwapped) val = byteSwap16(val); *pPt += sizeof(val); return val; } double byteSwapDouble(double a) /* Return byte-swapped version of a */ { -union {double whole; UBYTE bytes[4];} u,v; +union {double whole; UBYTE bytes[8];} u,v; u.whole = a; v.bytes[0] = u.bytes[7]; v.bytes[1] = u.bytes[6]; v.bytes[2] = u.bytes[5]; v.bytes[3] = u.bytes[4]; v.bytes[4] = u.bytes[3]; v.bytes[5] = u.bytes[2]; v.bytes[6] = u.bytes[1]; v.bytes[7] = u.bytes[0]; return v.whole; } double readDouble(FILE *f, boolean isSwapped) /* Read and optionally byte-swap double-precision floating point entity. */