Fix NULL-pointer arithmetic abuse in tests surfaced by clang
R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/12218051 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13614 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
9cb3a2e97d
commit
a2f0a01371
@ -53,6 +53,7 @@ static void InitializeVM() {
|
||||
|
||||
|
||||
TEST(MarkingDeque) {
|
||||
InitializeVM();
|
||||
int mem_size = 20 * kPointerSize;
|
||||
byte* mem = NewArray<byte>(20*kPointerSize);
|
||||
Address low = reinterpret_cast<Address>(mem);
|
||||
@ -60,19 +61,20 @@ TEST(MarkingDeque) {
|
||||
MarkingDeque s;
|
||||
s.Initialize(low, high);
|
||||
|
||||
Address address = NULL;
|
||||
Address original_address = reinterpret_cast<Address>(&s);
|
||||
Address current_address = original_address;
|
||||
while (!s.IsFull()) {
|
||||
s.PushBlack(HeapObject::FromAddress(address));
|
||||
address += kPointerSize;
|
||||
s.PushBlack(HeapObject::FromAddress(current_address));
|
||||
current_address += kPointerSize;
|
||||
}
|
||||
|
||||
while (!s.IsEmpty()) {
|
||||
Address value = s.Pop()->address();
|
||||
address -= kPointerSize;
|
||||
CHECK_EQ(address, value);
|
||||
current_address -= kPointerSize;
|
||||
CHECK_EQ(current_address, value);
|
||||
}
|
||||
|
||||
CHECK_EQ(NULL, address);
|
||||
CHECK_EQ(original_address, current_address);
|
||||
DeleteArray(mem);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user