nitpicker: fix memory accounting during realloc

Fixes #3794
This commit is contained in:
Alexander Boettcher 2020-06-30 17:52:20 +02:00 committed by Norman Feske
parent 62848b1a68
commit 103236fdca

View File

@ -470,7 +470,7 @@ Buffer *Session_component::realloc_buffer(Framebuffer::Mode mode, bool use_alpha
{ {
typedef Pixel_rgb888 PT; typedef Pixel_rgb888 PT;
_buffer_size = Chunky_texture<PT>::calc_num_bytes(mode.area, use_alpha); size_t const buffer_size = Chunky_texture<PT>::calc_num_bytes(mode.area, use_alpha);
/* /*
* Preserve the content of the original buffer if nitpicker has * Preserve the content of the original buffer if nitpicker has
@ -480,7 +480,7 @@ Buffer *Session_component::realloc_buffer(Framebuffer::Mode mode, bool use_alpha
if (texture()) { if (texture()) {
enum { PRESERVED_RAM = 128*1024 }; enum { PRESERVED_RAM = 128*1024 };
if (_env.pd().avail_ram().value > _buffer_size + PRESERVED_RAM) { if (_env.pd().avail_ram().value > buffer_size + PRESERVED_RAM) {
src_texture = static_cast<Texture<PT> const *>(texture()); src_texture = static_cast<Texture<PT> const *>(texture());
} else { } else {
warning("not enough RAM to preserve buffer content during resize"); warning("not enough RAM to preserve buffer content during resize");
@ -488,6 +488,9 @@ Buffer *Session_component::realloc_buffer(Framebuffer::Mode mode, bool use_alpha
} }
} }
/* set new buffer_size after _release_buffer(), which changes _buffer_size also */
_buffer_size = buffer_size;
Ram_quota const temporary_ram_upgrade = src_texture Ram_quota const temporary_ram_upgrade = src_texture
? Ram_quota{_buffer_size} : Ram_quota{0}; ? Ram_quota{_buffer_size} : Ram_quota{0};