Bug 89951 - Memory Leak in CairoFreeTypeFont::create
Summary: Memory Leak in CairoFreeTypeFont::create
Status: RESOLVED DUPLICATE of bug 89952
Alias: None
Product: poppler
Classification: Unclassified
Component: cairo backend (show other bugs)
Version: unspecified
Hardware: All All
: medium minor
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-08 06:20 UTC by Jason Crain
Modified: 2015-04-09 03:28 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
PDF with embedded TrueType font (2.17 KB, application/pdf)
2015-04-08 06:20 UTC, Jason Crain
Details
Free font's data->bytes in _ft_done_face (1001 bytes, patch)
2015-04-08 06:33 UTC, Jason Crain
Details | Splinter Review

Description Jason Crain 2015-04-08 06:20:17 UTC
Created attachment 114943 [details]
PDF with embedded TrueType font

Attached file shows a memory leak when rendered with the following code :

  int main() {
    cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 20, 20);
    cairo_t *cr = cairo_create (surface);

    PopplerDocument *doc = poppler_document_new_from_file ("file:///home/jason/CairoTrueTypeFont.pdf", NULL, NULL);
    PopplerPage *page = poppler_document_get_page (doc, 0);
    poppler_page_render (page, cr);

    g_object_unref (page);
    g_object_unref (doc);
    cairo_destroy (cr);
    cairo_surface_destroy (surface);
    cairo_debug_reset_static_data ();
  }

output of valgrind --tool=memcheck --leak-check=full --show-leak-kinds=definite ./a.out :

==19986== Warning: invalid file descriptor -1 in syscall close()
==19986== 
==19986== HEAP SUMMARY:
==19986==     in use at exit: 743,321 bytes in 5,522 blocks
==19986==   total heap usage: 7,263 allocs, 1,741 frees, 169,459,456 bytes allocated
==19986== 
==19986== 4,096 bytes in 1 blocks are definitely lost in loss record 498 of 506
==19986==    at 0x4C28C20: malloc (vg_replace_malloc.c:296)
==19986==    by 0x65A63B8: gmalloc(unsigned long, bool) (gmem.cc:110)
==19986==    by 0x65A6425: gmalloc (gmem.cc:120)
==19986==    by 0x6496C04: Stream::toUnsignedChars(int*, int, int) (Stream.h:147)
==19986==    by 0x64F6036: GfxFont::readEmbFontFile(XRef*, int*) (GfxFont.cc:908)
==19986==    by 0x4E7F241: CairoFreeTypeFont::create(GfxFont*, XRef*, FT_LibraryRec_*, bool) (CairoFontEngine.cc:429)
==19986==    by 0x4E8041E: CairoFontEngine::getFont(GfxFont*, PDFDoc*, bool, XRef*) (CairoFontEngine.cc:814)
==19986==    by 0x4E82401: CairoOutputDev::updateFont(GfxState*) (CairoOutputDev.cc:631)
==19986==    by 0x64EAE20: Gfx::opShowText(Object*, int) (Gfx.cc:3803)
==19986==    by 0x64DAF6B: Gfx::execOp(Object*, Object*, int) (Gfx.cc:904)
==19986==    by 0x64DA89C: Gfx::go(bool) (Gfx.cc:763)
==19986==    by 0x64DA6D0: Gfx::display(Object*, bool) (Gfx.cc:729)
Comment 1 Jason Crain 2015-04-08 06:33:25 UTC
Created attachment 114944 [details] [review]
Free font's data->bytes in _ft_done_face

Attached patch frees the font's bytes when the font is destroyed in _ft_done_face.
Comment 2 Jason Crain 2015-04-09 03:28:34 UTC

*** This bug has been marked as a duplicate of bug 89952 ***


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.