Skip to content

Commit

Permalink
Merge pull request #148 from pitrou:ubsan-ptr-add-overflow
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 463090354
  • Loading branch information
pwnall committed Jul 27, 2022
2 parents 44caf79 + 64df9f2 commit af720f9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion snappy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ static inline bool Copy64BytesWithPatternExtension(char* dst, size_t offset) {
if (SNAPPY_PREDICT_TRUE(offset < 16)) {
if (SNAPPY_PREDICT_FALSE(offset == 0)) return false;
// Extend the pattern to the first 16 bytes.
for (int i = 0; i < 16; i++) dst[i] = dst[i - offset];
// The simpler formulation of `dst[i - offset]` induces undefined behavior.
for (int i = 0; i < 16; i++) dst[i] = (dst - offset)[i];
// Find a multiple of pattern >= 16.
static std::array<uint8_t, 16> pattern_sizes = []() {
std::array<uint8_t, 16> res;
Expand Down

0 comments on commit af720f9

Please sign in to comment.