summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMonsta <[email protected]>2014-11-03 14:52:30 +0300
committerinfirit <[email protected]>2014-12-23 13:57:32 +0100
commit2347bbac04098a28109ac86c7bbd132e7cf7a488 (patch)
tree9a745768aee2b43344c6ab5ec6542322287c0487 /src
parent2c409777d74acf08f83da031dc589bd438a45220 (diff)
downloadeom-2347bbac04098a28109ac86c7bbd132e7cf7a488.tar.bz2
eom-2347bbac04098a28109ac86c7bbd132e7cf7a488.tar.xz
open the file a bit later to avoid possible leak on g_return_val_if_fail
Diffstat (limited to 'src')
-rw-r--r--src/eom-image-jpeg.c16
1 files changed, 8 insertions, 8 deletions
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) {