Skip to content

Commit 5e4637d

Browse files
author
Matthew Cline
committed
mightBeVec() fix
Vector length might not be a multiple of 4 if, for example, it's a vector of uint8_t or uint16_t. However, the actual memory allocated to the vector should be 4 byte aligned, so test for that instead.
1 parent bde3616 commit 5e4637d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

plugins/vectors.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ static bool mightBeVec(vector<t_memrange> &heap_ranges,
7171
if ((vec->start > vec->end) || (vec->end > vec->alloc_end))
7272
return false;
7373

74-
if ((vec->end - vec->start) % 4 != 0)
74+
// Vector length might not be a multiple of 4 if, for example,
75+
// it's a vector of uint8_t or uint16_t. However, the actual memory
76+
// allocated to the vector should be 4 byte aligned.
77+
if ((vec->start % 4 != 0) || (vec->alloc_end % 4 != 0))
7578
return false;
7679

7780
for (size_t i = 0; i < heap_ranges.size(); i++)

0 commit comments

Comments
 (0)