aboutsummaryrefslogtreecommitdiff
path: root/Foundation
diff options
context:
space:
mode:
authorGravatar Eugene Hermann <39246518+eughermann@users.noreply.github.com>2018-07-25 14:07:03 -0700
committerGravatar Thomas Van Lenten <thomasvl@google.com>2018-07-25 17:25:49 -0400
commit640815dcd6fa74bfd103ec89bd5acce6a371bcf8 (patch)
tree918d719cbbfbfe2424b3167431738a7c01728964 /Foundation
parent202eaa313ed62dc08e813c75aba5bc941736c0c9 (diff)
Fix Undefined Behavior, left shift of negative value, signed integer overflow.
ubsan output: .../google_toolbox_for_mac/Foundation/GTMStringEncoding.m:204:16: runtime error: left shift of 10368305 by 8 places cannot be represented in type 'int' .../google_toolbox_for_mac/Foundation/GTMStringEncoding.m:312:16: runtime error: left shift of 42406098 by 6 places cannot be represented in type 'int' TESTED=Earth iOS --featires=ubsan
Diffstat (limited to 'Foundation')
-rw-r--r--Foundation/GTMStringEncoding.m4
1 files changed, 2 insertions, 2 deletions
diff --git a/Foundation/GTMStringEncoding.m b/Foundation/GTMStringEncoding.m
index 7578e86..6bc496c 100644
--- a/Foundation/GTMStringEncoding.m
+++ b/Foundation/GTMStringEncoding.m
@@ -196,7 +196,7 @@ GTM_INLINE int lcm(int a, int b) {
unsigned char *outBuf = (unsigned char *)[outData mutableBytes];
NSUInteger outPos = 0;
- int buffer = inBuf[inPos++];
+ unsigned int buffer = inBuf[inPos++];
int bitsLeft = 8;
while (bitsLeft > 0 || inPos < inLen) {
if (bitsLeft < shift_) {
@@ -275,7 +275,7 @@ GTM_INLINE int lcm(int a, int b) {
unsigned char *outBuf = (unsigned char *)[outData mutableBytes];
NSUInteger outPos = 0;
- int buffer = 0;
+ unsigned int buffer = 0;
int bitsLeft = 0;
BOOL expectPad = NO;
for (NSUInteger i = 0; i < inLen; i++) {