Fix allocation.

This commit is contained in:
Christian Speckner 2023-08-29 23:32:34 +02:00
parent 374b49bf21
commit 7c5d302f4f
1 changed files with 2 additions and 2 deletions

View File

@ -394,11 +394,11 @@ bool PNGLibrary::allocateStorage(size_t width, size_t height, bool hasAlpha)
// Create space for the entire image (3(4) bytes per pixel in RGB(A) format) // Create space for the entire image (3(4) bytes per pixel in RGB(A) format)
const size_t req_buffer_size = width * height * (hasAlpha ? 4 : 3); const size_t req_buffer_size = width * height * (hasAlpha ? 4 : 3);
if(req_buffer_size > ReadInfo.buffer.capacity()) if(req_buffer_size > ReadInfo.buffer.capacity())
ReadInfo.buffer.reserve(req_buffer_size * 1.5); ReadInfo.buffer.resize(req_buffer_size * 1.5);
const size_t req_row_size = height; const size_t req_row_size = height;
if(req_row_size > ReadInfo.row_pointers.capacity()) if(req_row_size > ReadInfo.row_pointers.capacity())
ReadInfo.row_pointers.reserve(req_row_size * 1.5); ReadInfo.row_pointers.resize(req_row_size * 1.5);
ReadInfo.width = static_cast<png_uint_32>(width); ReadInfo.width = static_cast<png_uint_32>(width);
ReadInfo.height = static_cast<png_uint_32>(height); ReadInfo.height = static_cast<png_uint_32>(height);