summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston Sequoia <jeremyhu@apple.com>2022-12-03 15:14:25 -0800
committerJeremy Huddleston Sequoia <jeremyhu@apple.com>2022-12-03 15:17:55 -0800
commita992510baba1ae46f0c1a4013f955cc74ecb212e (patch)
treea7dce4909e19b9b68c8f5aeded3981b92f50abb0
parent592c3d2b8f56679b35f2b8b97aeba3f8e3fb3b9e (diff)
Address s UBSan warning about int left shift overflow
ident.c:220:22: runtime error: left shift of 255 by 24 places cannot be represented in type 'int' Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-rw-r--r--ident.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ident.c b/ident.c
index bbe1687..920a414 100644
--- a/ident.c
+++ b/ident.c
@@ -216,10 +216,12 @@ getInt32(fontFile *f, int format)
if(rc != 4)
return -1;
+ unsigned int u[4] = {c[0], c[1], c[2], c[3]};
+
if(format & (1 << 2)) {
- return (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | (c[3]);
+ return (int)((u[0] << 24) | (u[1] << 16) | (u[2] << 8) | (u[3]));
} else {
- return (c[0]) | (c[1] << 8) | (c[2] << 16) | (c[3] << 24);
+ return (int)((u[0]) | (u[1] << 8) | (u[2] << 16) | (u[3] << 24));
}
}