<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Memory leaks in font-related code"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=56566">56566</a>
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>ajohnson@redneon.com
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Memory leaks in font-related code
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>cairo-bugs@cairographics.org
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>major
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>kiyoka@gmail.com
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>1.12.6
          </td>
        </tr>

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

        <tr>
          <th>Product</th>
          <td>cairo
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=69279" name="attach_69279" title="The patch">attachment 69279</a> <a href="attachment.cgi?id=69279&action=edit" title="The patch">[details]</a></span>
The patch

I've located two memory leaks in the pdf backend.

In cairo-type1-subset.c, _cairo_type1_font_subset_fini doesn't free
font->cleartext (set by cairo_type1_font_subset_decrypt_eexec_segment).

In cairo-cff-subset.c, _cairo_cff_font_create can exit without freeing
font->font_name and/or font->data; _cairo_cff_font_load_opentype_cff is called
to allocate font_name, then _cairo_cff_font_load_cff is called to allocate
font->data, then _cairo_cff_font_load_cff's return status is checked and if it
failed, it jumps to fail1. This can cause font_name to leak since the fail1
target only frees the font variable. In addition, _cairo_cff_font_load_cff can
fail -after- allocating data, and then data won't be freed either.

I've attached a patch against the latest (5a6e1d) commit in the master repo and
a test case with a pdf I found on the web that triggers it.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>