diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-21 22:03:00 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-21 22:03:00 +0000 |
commit | 104c81a649d539c0fc2e4c8bb08d8e1163179c53 (patch) | |
tree | f60c53fdb038a04783fb5c273afc8a2179857e5f /chrome/common | |
parent | d841205ef77d7f98bf780516d3be96a3ba6c6f29 (diff) | |
download | chromium_src-104c81a649d539c0fc2e4c8bb08d8e1163179c53.zip chromium_src-104c81a649d539c0fc2e4c8bb08d8e1163179c53.tar.gz chromium_src-104c81a649d539c0fc2e4c8bb08d8e1163179c53.tar.bz2 |
Fix a leak when we fail to load a gdkpixbuf. I meant to do this in
the last change, but forgot.
Review URL: http://codereview.chromium.org/69042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14143 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/resource_bundle_linux.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/chrome/common/resource_bundle_linux.cc b/chrome/common/resource_bundle_linux.cc index 2fe2a31..e982db8 100644 --- a/chrome/common/resource_bundle_linux.cc +++ b/chrome/common/resource_bundle_linux.cc @@ -30,24 +30,24 @@ namespace { // has a ref count of 1 so the caller must call g_object_unref to free the // memory. GdkPixbuf* LoadPixbuf(std::vector<unsigned char>& data) { - GdkPixbufLoader* loader = gdk_pixbuf_loader_new(); - bool ok = gdk_pixbuf_loader_write(loader, static_cast<guint8*>(data.data()), - data.size(), NULL); + ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); + bool ok = gdk_pixbuf_loader_write(loader.get(), + static_cast<guint8*>(data.data()), data.size(), NULL); if (!ok) return NULL; // Calling gdk_pixbuf_loader_close forces the data to be parsed by the // loader. We must do this before calling gdk_pixbuf_loader_get_pixbuf. - ok = gdk_pixbuf_loader_close(loader, NULL); + ok = gdk_pixbuf_loader_close(loader.get(), NULL); if (!ok) return NULL; - GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); + GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader.get()); if (!pixbuf) return NULL; // The pixbuf is owned by the loader, so add a ref so when we delete the - // loader, the pixbuf still exists. + // loader (when the ScopedGObject goes out of scope), the pixbuf still + // exists. g_object_ref(pixbuf); - g_object_unref(loader); return pixbuf; } |