summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2020-01-18 19:50:38 +0100
committerMarcus Meissner <marcus@jet.franken.de>2020-01-18 19:50:38 +0100
commitcf37dc7934bbb10dc5d0c17db260a25aa2831595 (patch)
tree30312a86b762e6fc0d5f1ae55799e919543d1759
parent75aa73267fdb1e0ebfbc00369e7312bac43d0566 (diff)
downloadlibexif-cf37dc7934bbb10dc5d0c17db260a25aa2831595.tar.gz
libexif-cf37dc7934bbb10dc5d0c17db260a25aa2831595.tar.bz2
libexif-cf37dc7934bbb10dc5d0c17db260a25aa2831595.zip
cast to unsigned int before shifting left
(weird integer promotion, a unsigned char will be first tried to be promoted to "int" apparently, so we need to cast it to avoid implicit behaviour) fixes https://github.com/libexif/libexif/issues/20
-rw-r--r--libexif/exif-utils.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libexif/exif-utils.c b/libexif/exif-utils.c
index 9083ddc..8a92907 100644
--- a/libexif/exif-utils.c
+++ b/libexif/exif-utils.c
@@ -132,9 +132,9 @@ exif_get_slong (const unsigned char *b, ExifByteOrder order)
if (!b) return 0;
switch (order) {
case EXIF_BYTE_ORDER_MOTOROLA:
- return ((b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]);
+ return (((uint32_t)b[0] << 24) | ((uint32_t)b[1] << 16) | ((uint32_t)b[2] << 8) | (uint32_t)b[3]);
case EXIF_BYTE_ORDER_INTEL:
- return ((b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0]);
+ return (((uint32_t)b[3] << 24) | ((uint32_t)b[2] << 16) | ((uint32_t)b[1] << 8) | (uint32_t)b[0]);
}
/* Won't be reached */