| OLD | NEW |
| 1 // Copyright 2014 Google Inc. All Rights Reserved. | 1 // Copyright 2014 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 bytes, | 229 bytes, |
| 230 0, | 230 0, |
| 231 parameters_.trailer_padding_size + sizeof(BlockTrailer), | 231 parameters_.trailer_padding_size + sizeof(BlockTrailer), |
| 232 &block_layout); | 232 &block_layout); |
| 233 if (alloc != nullptr) { | 233 if (alloc != nullptr) { |
| 234 heap_id = heaps[i]; | 234 heap_id = heaps[i]; |
| 235 break; | 235 break; |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 | 238 |
| 239 // The allocation might fail because its size exceed the maximum size that | 239 // The allocation can fail if we're out of memory or if the size exceed the |
| 240 // we can represent in the BlockHeader structure, try to do an unguarded | 240 // maximum allocation size. |
| 241 // allocation. | |
| 242 if (alloc == nullptr) | 241 if (alloc == nullptr) |
| 243 return DoUnguardedAllocation(GetHeapFromId(heap_id), shadow_, bytes); | 242 return nullptr; |
| 244 | 243 |
| 245 DCHECK_NE(static_cast<void*>(nullptr), alloc); | 244 DCHECK_NE(static_cast<void*>(nullptr), alloc); |
| 246 DCHECK_EQ(0u, reinterpret_cast<size_t>(alloc) % kShadowRatio); | 245 DCHECK_EQ(0u, reinterpret_cast<size_t>(alloc) % kShadowRatio); |
| 247 BlockInfo block = {}; | 246 BlockInfo block = {}; |
| 248 BlockInitialize(block_layout, alloc, &block); | 247 BlockInitialize(block_layout, alloc, &block); |
| 249 | 248 |
| 250 // Poison the redzones in the shadow memory as early as possible. | 249 // Poison the redzones in the shadow memory as early as possible. |
| 251 shadow_->PoisonAllocatedBlock(block); | 250 shadow_->PoisonAllocatedBlock(block); |
| 252 | 251 |
| 253 block.header->alloc_stack = stack_cache_->SaveStackTrace(stack); | 252 block.header->alloc_stack = stack_cache_->SaveStackTrace(stack); |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 if (trailer_has_valid_heap_id) | 1123 if (trailer_has_valid_heap_id) |
| 1125 return block_info->trailer->heap_id; | 1124 return block_info->trailer->heap_id; |
| 1126 | 1125 |
| 1127 // Unfortunately, there's no way to know which heap this block belongs to. | 1126 // Unfortunately, there's no way to know which heap this block belongs to. |
| 1128 return 0; | 1127 return 0; |
| 1129 } | 1128 } |
| 1130 | 1129 |
| 1131 } // namespace heap_managers | 1130 } // namespace heap_managers |
| 1132 } // namespace asan | 1131 } // namespace asan |
| 1133 } // namespace agent | 1132 } // namespace agent |
| OLD | NEW |