Commit a113e02 1 parent 8138055 commit a113e02 Copy full SHA for a113e02
File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -83,9 +83,11 @@ void* Zone::New(int size) {
83
83
#else
84
84
size;
85
85
#endif
86
-
87
- if (size_with_redzone > limit_ - position_) {
88
- result = NewExpand (size_with_redzone);
86
+ const uintptr_t limit = reinterpret_cast <uintptr_t >(limit_);
87
+ const uintptr_t position = reinterpret_cast <uintptr_t >(position_);
88
+ // position_ > limit_ can be true after the alignment correction above.
89
+ if (limit < position || size_with_redzone > limit - position) {
90
+ result = NewExpand (size_with_redzone);
89
91
} else {
90
92
position_ += size_with_redzone;
91
93
}
@@ -202,7 +204,10 @@ Address Zone::NewExpand(int size) {
202
204
// Make sure the requested size is already properly aligned and that
203
205
// there isn't enough room in the Zone to satisfy the request.
204
206
DCHECK (size == RoundDown (size, kAlignment ));
205
- DCHECK (size > limit_ - position_);
207
+ DCHECK (limit_ < position_ ||
208
+ reinterpret_cast <uintptr_t >(limit_) -
209
+ reinterpret_cast <uintptr_t >(position_) <
210
+ size);
206
211
207
212
// Compute the new segment size. We use a 'high water mark'
208
213
// strategy, where we increase the segment size every time we expand
You can’t perform that action at this time.
0 commit comments