diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2018-01-31 11:59:57 -0500 |
---|---|---|
committer | Thomas Van Lenten <thomasvl@google.com> | 2018-01-31 12:36:54 -0500 |
commit | 953adb16ff2f982d54dd812b51df5fdb392732f8 (patch) | |
tree | f6a855939173eaf8a5a4d6bfc84a87fff8255a0e /objectivec/GPBUtilities.m | |
parent | b718551571983f281d065e818da4fd9ca5723d89 (diff) | |
download | protobuf-953adb16ff2f982d54dd812b51df5fdb392732f8.tar.gz protobuf-953adb16ff2f982d54dd812b51df5fdb392732f8.tar.bz2 protobuf-953adb16ff2f982d54dd812b51df5fdb392732f8.zip |
Add casts to removed undefined behaviors around shifts.
Fixes #4246
Fixes #4247
Diffstat (limited to 'objectivec/GPBUtilities.m')
-rw-r--r-- | objectivec/GPBUtilities.m | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/objectivec/GPBUtilities.m b/objectivec/GPBUtilities.m index 77ea9577..25746569 100644 --- a/objectivec/GPBUtilities.m +++ b/objectivec/GPBUtilities.m @@ -291,7 +291,7 @@ BOOL GPBGetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber) { } else { NSCAssert(idx != GPBNoHasBit, @"Invalid has bit."); uint32_t byteIndex = idx / 32; - uint32_t bitMask = (1 << (idx % 32)); + uint32_t bitMask = (1U << (idx % 32)); BOOL hasIvar = (self->messageStorage_->_has_storage_[byteIndex] & bitMask) ? YES : NO; return hasIvar; @@ -315,7 +315,7 @@ void GPBSetHasIvar(GPBMessage *self, int32_t idx, uint32_t fieldNumber, NSCAssert(idx != GPBNoHasBit, @"Invalid has bit."); uint32_t *has_storage = self->messageStorage_->_has_storage_; uint32_t byte = idx / 32; - uint32_t bitMask = (1 << (idx % 32)); + uint32_t bitMask = (1U << (idx % 32)); if (value) { has_storage[byte] |= bitMask; } else { |