Make sure aligned_alloc args are valid
This commit is contained in:
@@ -93,7 +93,8 @@ private:
|
|||||||
* @throws std::bad_alloc if memory allocation fails
|
* @throws std::bad_alloc if memory allocation fails
|
||||||
*/
|
*/
|
||||||
static Block *create(size_t size, Block *prev) {
|
static Block *create(size_t size, Block *prev) {
|
||||||
void *memory = std::aligned_alloc(alignof(Block), sizeof(Block) + size);
|
void *memory = std::aligned_alloc(
|
||||||
|
alignof(Block), align_up(sizeof(Block) + size, alignof(Block)));
|
||||||
if (!memory) {
|
if (!memory) {
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user