<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Memory Leak in CairoFreeTypeFont::create"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=89951">89951</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Memory Leak in CairoFreeTypeFont::create
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>poppler
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>minor
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>cairo backend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>poppler-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jason@aquaticape.us
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=114943" name="attach_114943" title="PDF with embedded TrueType font">attachment 114943</a> <a href="attachment.cgi?id=114943&action=edit" title="PDF with embedded TrueType font">[details]</a></span>
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)</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>