From 2347bbac04098a28109ac86c7bbd132e7cf7a488 Mon Sep 17 00:00:00 2001 From: Monsta Date: Mon, 3 Nov 2014 14:52:30 +0300 Subject: open the file a bit later to avoid possible leak on g_return_val_if_fail --- src/eom-image-jpeg.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/eom-image-jpeg.c') diff --git a/src/eom-image-jpeg.c b/src/eom-image-jpeg.c index 8d9e319..576df36 100644 --- a/src/eom-image-jpeg.c +++ b/src/eom-image-jpeg.c @@ -365,6 +365,14 @@ _save_any_as_jpeg (EomImage *image, const char *file, EomImageSaveInfo *source, priv = image->priv; pixbuf = priv->image; + rowstride = gdk_pixbuf_get_rowstride (pixbuf); + w = gdk_pixbuf_get_width (pixbuf); + h = gdk_pixbuf_get_height (pixbuf); + + /* no image data? abort */ + pixels = gdk_pixbuf_get_pixels (pixbuf); + g_return_val_if_fail (pixels != NULL, FALSE); + outfile = fopen (file, "wb"); if (outfile == NULL) { g_set_error (error, /* FIXME: Better error message */ @@ -375,14 +383,6 @@ _save_any_as_jpeg (EomImage *image, const char *file, EomImageSaveInfo *source, return FALSE; } - rowstride = gdk_pixbuf_get_rowstride (pixbuf); - w = gdk_pixbuf_get_width (pixbuf); - h = gdk_pixbuf_get_height (pixbuf); - - /* no image data? abort */ - pixels = gdk_pixbuf_get_pixels (pixbuf); - g_return_val_if_fail (pixels != NULL, FALSE); - /* allocate a small buffer to convert image data */ buf = g_try_malloc (w * 3 * sizeof (guchar)); if (!buf) { -- cgit v1.2.1