mirror of https://github.com/OpenTTD/OpenTTD
Fix: Memory leak in CoreTextFontCache. (#12662)
Temporary buffer for rendering glyphs was not freed after use. Instead let CGBitmapContextCreate() handle the buffer. > data may be a pointer to pixels. If you pass NULL, the context will create its own buffer and free that buffer itself later. If you pass your own buffer, the context will not free it; it remains your buffer that you must free after you release the context, hopefully for the last time.pull/12650/head
parent
071796660d
commit
f87c6990b0
|
@ -242,8 +242,8 @@ const Sprite *CoreTextFontCache::InternalGetGlyph(GlyphID key, bool use_aa)
|
|||
|
||||
/* We only need the alpha channel, as we apply our own colour constants to the sprite. */
|
||||
int pitch = Align(bb_width, 16);
|
||||
uint8_t *bmp = CallocT<uint8_t>(bb_height * pitch);
|
||||
CFAutoRelease<CGContextRef> context(CGBitmapContextCreate(bmp, bb_width, bb_height, 8, pitch, nullptr, kCGImageAlphaOnly));
|
||||
CFAutoRelease<CGContextRef> context(CGBitmapContextCreate(nullptr, bb_width, bb_height, 8, pitch, nullptr, kCGImageAlphaOnly));
|
||||
const uint8_t *bmp = static_cast<uint8_t *>(CGBitmapContextGetData(context.get()));
|
||||
/* Set antialias according to requirements. */
|
||||
CGContextSetAllowsAntialiasing(context.get(), use_aa);
|
||||
CGContextSetAllowsFontSubpixelPositioning(context.get(), use_aa);
|
||||
|
|
Loading…
Reference in New Issue