mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-28 18:32:50 +00:00
Throw a bad_alloc when there is not enough memory for ImageBuffer (fix #4316)
Fix regression introduced in aeeef8e255c2d83a1b3e3cb2858939233d5a5d0b when we replaced the std::vector with aligned memory allocations (or just malloc/free).
This commit is contained in:
parent
0134c74926
commit
d70801e88b
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (C) 2019-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -25,6 +25,8 @@ namespace doc {
|
||||
ImageBuffer(std::size_t size = 1)
|
||||
: m_size(doc_align_size(size))
|
||||
, m_buffer((uint8_t*)doc_aligned_alloc(m_size)) {
|
||||
if (!m_buffer)
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
~ImageBuffer() noexcept {
|
||||
@ -44,6 +46,8 @@ namespace doc {
|
||||
|
||||
m_size = doc_align_size(size);
|
||||
m_buffer = (uint8_t*)doc_aligned_alloc(m_size);
|
||||
if (!m_buffer)
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user