Commit f79c41be authored by Peter Pentchev's avatar Peter Pentchev

Fix a signed/unsigned bug in the bigendian conversion.

parent 2303a961
......@@ -10,6 +10,7 @@ Change log for hexer, the multi-view binary editor
- declare some functions as printf-like
- handle short reads/writes and read/write errors
- bump the year on my copyright notice
- fix a signed/unsigned char bug when reading the swapfile
0.1.8 2014/09/11
- fix a crash when inserting or replacing a half-byte
......
......@@ -100,12 +100,13 @@ he_bigendian(unsigned long x)
static unsigned long
he_bigendian_to_ulong(char *bigendian)
{
const unsigned char * const be = (const unsigned char *)bigendian;
unsigned long x;
x = (unsigned long)bigendian[3]
+ ((unsigned long)bigendian[2] << 8)
+ ((unsigned long)bigendian[1] << 16)
+ ((unsigned long)bigendian[0] << 24);
x = (unsigned long)be[3]
+ ((unsigned long)be[2] << 8)
+ ((unsigned long)be[1] << 16)
+ ((unsigned long)be[0] << 24);
return x;
}
/* he_bigendian_to_long */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment