Open X-Ryl669 opened 2 years ago
Found this via Valgrind:
VBitmap make_surface( size_t width, size_t height, VBitmap::Format format = VBitmap::Format::ARGB32_Premultiplied) { if (mCache.empty()) return {width, height, format}; auto surface = mCache.back(); surface.reset(width, height, format); mCache.pop_back(); return surface; } void release_surface(VBitmap &surface) { mCache.push_back(surface); }
Here we have the sequence:
VBitmap & surface = mCache.back()
cache.pop_back();
return surface;
Instead of auto surface here, it should be VBitmap surface since auto resolve to a reference (vector::back() returns a reference on its last element)
auto surface
VBitmap surface
vector::back()
Found this via Valgrind:
Here we have the sequence:
VBitmap & surface = mCache.back()
=> we take a reference on the last elementcache.pop_back();
=> delete the last element in the vectorreturn surface;
=> return a dangling reference on a deleted elementInstead of
auto surface
here, it should beVBitmap surface
since auto resolve to a reference (vector::back()
returns a reference on its last element)