On Fri, May 15, 2015 at 8:33 PM, Werner LEMBERG <[email protected]> wrote:
>
> > I'm porting FreeType-2.5.5 to an embedded RTOS. However, I found
> > memory leak in looped `FT_Load_Char(fft->face, *text_ptr,
> > FT_LOAD_RENDER)` while the memory won't leak if I set the load_flags
> > ORed with FT_LOAD_NO_HINTING.
> >
> > So I dive into the source code and found in the tt_loader_init, the
> > `size->bytecode_ready` and `size->cvt_ready` are always -1, causing
> > `tt_size_ready_bytecode` run on the same `size` repeatedly. So the
> > previous content of size will be leaked.
>
> Please provide a stand-alone, compilable minimum example that exhibits
> the problem. I can then do some debugging.
>
>
>
Sorry for the delay. Here is the program:
===================
#include <unistd.h>
#include <stdint.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#define handle_error(msg, err) \
do { printf(msg); exit(err); } while (0)
int main(int argc, char *argv[])
{
FT_Error err = 0;
FT_Face face;
FT_Library library;
err = FT_Init_FreeType(&library);
if (err)
handle_error("failed to Init FreeType\n", err);
err = FT_New_Face(library, "digital-number.ttf", 0, &face);
if (err)
handle_error("failed to New Face\n", err);
err = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
if (err)
{
err = FT_Select_Charmap(face, FT_ENCODING_ADOBE_LATIN_1);
}
err = FT_Set_Pixel_Sizes(face, 0, 110);
if (err != 0)
{
handle_error("failed to set Pixel Size\n", err);
}
for (;;)
{
FT_ULong char_code = '0';
FT_GlyphSlot slot;
slot = face->glyph;
err = FT_Load_Char(face, char_code, FT_LOAD_RENDER);
if (err)
handle_error("failed to load char\n", err);
usleep(1000);
}
return 0;
}
===================
I attached the font as a 7z archive. Compile and run this program you will
see the memory usage of the process is going up quickly.
I also figured out that this bug is font specific. I tried an other font
and there won't be leaks. My font is generated by FontForge if that matter.
--
Cheers,
Grissiom
digital-number.7z
Description: application/7z-compressed
_______________________________________________ Freetype mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/freetype
