diff --git a/TinyEXIF.cpp b/TinyEXIF.cpp index 2fadd6a..b4370b6 100644 --- a/TinyEXIF.cpp +++ b/TinyEXIF.cpp @@ -95,6 +95,9 @@ namespace Tools { namespace TinyEXIF { +uint32_t const _ONE32 = 1; +bool const IS_LITTLE_ENDIAN = (reinterpret_cast(&_ONE32))[0] == 1; + enum JPEG_MARKERS { JM_START = 0xFF, JM_SOF0 = 0xC0, @@ -945,10 +948,10 @@ int EXIFInfo::parseFromEXIFSegment(const uint8_t* buf, unsigned len) { return PARSE_CORRUPT_DATA; bool alignIntel; if (buf[offs] == 'I' && buf[offs+1] == 'I') - alignIntel = true; // 1: Intel byte alignment + alignIntel = IS_LITTLE_ENDIAN; // 1: Intel byte alignment else if (buf[offs] == 'M' && buf[offs+1] == 'M') - alignIntel = false; // 0: Motorola byte alignment + alignIntel = !IS_LITTLE_ENDIAN; // 0: Motorola byte alignment else return PARSE_UNKNOWN_BYTEALIGN; EntryParser parser(buf, len, offs, alignIntel);