<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 _cairo_default_context_set_source_surface"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=87766">87766</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>memory leak in _cairo_default_context_set_source_surface
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>cairo
          </td>
        </tr>

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

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

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

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>general
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>chris@chris-wilson.co.uk
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>sixtysix@inwind.it
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>cairo-bugs@cairographics.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=111398" name="attach_111398" title="testcase">attachment 111398</a> <a href="attachment.cgi?id=111398&action=edit" title="testcase">[details]</a></span>
testcase

running the attached test case valgrind reports:

<span class="quote">>==3== 160 bytes in 1 blocks are definitely lost in loss record 1 of 7
>==3==    at 0x4A06BCF: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
>==3==    by 0x4C645AC: _cairo_pattern_create_solid (cairo/src/cairo-pattern.c:605)
>==3==    by 0x4C645EB: _cairo_pattern_create_in_error.part.20 (cairo/src/cairo-pattern.c:628)
>==3==    by 0x4C3D0E4: _cairo_default_context_set_source_surface (cairo/src/cairo-default-context.c:327)
>==3==    by 0x4C349EE: cairo_set_source_surface (cairo/src/cairo.c:766)
>==3==    by 0x400803: main (/home/massimo/devel/tmp/test-cairo-set-source-surface.c:12)</span >

_cairo_default_context_set_source_surface, when the surface passed in
is in error, returns a pattern->status without destroying the pattern
created which is not a static pattern nor part of a cairo owned set
of error patterns:

<a href="http://cgit.freedesktop.org/cairo/tree/src/cairo-default-context.c#n327">http://cgit.freedesktop.org/cairo/tree/src/cairo-default-context.c#n327</a>

Similarly cairo_get_source returns a leaked pattern when the context
passed in is in error:

<a href="http://cgit.freedesktop.org/cairo/tree/src/cairo.c#n833">http://cgit.freedesktop.org/cairo/tree/src/cairo.c#n833</a>

Valgrind reports this one running:

CAIRO_TEST_TARGET=image valgrind --leak-check=full .libs/cairo-test-suite -f 
api-special-cases</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>