Bug 6186 - Memory leak in emit_image_rgb_data (src/cairo-pdf-surface.c)
Summary: Memory leak in emit_image_rgb_data (src/cairo-pdf-surface.c)
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: pdf backend (show other bugs)
Version: 1.1.1
Hardware: All All
: high minor
Assignee: Kristian Høgsberg
QA Contact: cairo-bugs mailing list
URL: http://gitweb.freedesktop.org/?p=cair...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-09 05:35 UTC by Ken Herron
Modified: 2006-03-13 12:19 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Ken Herron 2006-03-09 05:35:12 UTC
This was found through a coverity scan of the mozilla source tree.

In |emit_image_rgb_data| (src/cairo-pdf-surface.c) around line 645 some memory
is allocated and stored in a variable |rgb|. Around line 654
|cairo_image_surface_create| is called, which may return NULL. If it does, then
|emit_image_rgb_data| returns (at line 658) without freeing |rgb|.
Comment 1 Carl Worth 2006-03-14 07:19:10 UTC
This is now fixed in cairo 1.1.1.

-Carl

diff-tree fc51a78a1ed5f7649ce55ab30fc42939a9b295d1 (from
25cccaaa1f6d337a1a0423a298f94456e72a820a)
Author: Carl Worth <cworth@cworth.org>
Date:   Mon Mar 13 12:14:47 2006 -0800

    cairo-pdf-surface: Close memory leak during OOM handling.

    This fixes bug #6186:

        Memory leak in emit_image_rgb_data (src/cairo-pdf-surface.c)
        https://bugs.freedesktop.org/show_bug.cgi?id=6186

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index cb8287b..6d18196 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -654,8 +654,10 @@ emit_image_rgb_data (cairo_pdf_document_
        opaque = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
                                             image->width,
                                             image->height);
-       if (opaque->status)
+       if (opaque->status) {
+           free (rgb);
            return 0;
+       }

        _cairo_pattern_init_for_surface (&pattern.surface, &image->base);



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.