summaryrefslogtreecommitdiff
path: root/thumbnailer/atril-thumbnailer.c
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-01-22 16:56:02 +0100
committerraveit65 <[email protected]>2020-02-02 00:41:52 +0100
commit477b077e6b8420a11d482156746623fd60556356 (patch)
treed5f7887f4a57b1dc1fa080aac71890bb00a36c12 /thumbnailer/atril-thumbnailer.c
parenta70e19a51423b855b9da8d7f9ed40d396a534c67 (diff)
downloadatril-477b077e6b8420a11d482156746623fd60556356.tar.bz2
atril-477b077e6b8420a11d482156746623fd60556356.tar.xz
thumbnailer: Fix memory leak
Diffstat (limited to 'thumbnailer/atril-thumbnailer.c')
-rw-r--r--thumbnailer/atril-thumbnailer.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/thumbnailer/atril-thumbnailer.c b/thumbnailer/atril-thumbnailer.c
index 708e4800..4ab529df 100644
--- a/thumbnailer/atril-thumbnailer.c
+++ b/thumbnailer/atril-thumbnailer.c
@@ -32,7 +32,7 @@ static gboolean finished = TRUE;
static gint size = THUMBNAIL_SIZE;
static gboolean time_limit = TRUE;
-static const gchar **file_arguments;
+static char **file_arguments = NULL;
static const GOptionEntry goption_options[] = {
{ "size", 's', 0, G_OPTION_ARG_INT, &size, NULL, "SIZE" },
@@ -227,15 +227,17 @@ main (int argc, char *argv[])
g_error_free (error);
print_usage (context);
g_option_context_free (context);
+ if (file_arguments)
+ g_strfreev (file_arguments);
return -1;
}
- input = file_arguments ? file_arguments[0] : NULL;
- output = input ? file_arguments[1] : NULL;
- if (!input || !output) {
+ if (file_arguments == NULL || g_strv_length (file_arguments) != 2) {
print_usage (context);
g_option_context_free (context);
+ if (file_arguments)
+ g_strfreev (file_arguments);
return -1;
}
@@ -244,14 +246,18 @@ main (int argc, char *argv[])
if (size < 1) {
g_printerr ("Size cannot be smaller than 1 pixel\n");
+ g_strfreev (file_arguments);
+
return -1;
}
input = file_arguments[0];
output = file_arguments[1];
- if (!ev_init ())
+ if (!ev_init ()) {
+ g_strfreev (file_arguments);
return -1;
+ }
file = g_file_new_for_commandline_arg (input);
document = atril_thumbnailer_get_document (file);
@@ -259,12 +265,16 @@ main (int argc, char *argv[])
if (!document) {
ev_shutdown ();
+ g_strfreev (file_arguments);
+
return -2;
}
if (!EV_IS_DOCUMENT_THUMBNAILS (document)) {
g_object_unref (document);
ev_shutdown ();
+ g_strfreev (file_arguments);
+
return -2;
}
@@ -288,6 +298,7 @@ main (int argc, char *argv[])
g_object_unref (document);
ev_shutdown ();
+ g_strfreev (file_arguments);
return data.success ? 0 : -2;
}
@@ -295,12 +306,15 @@ main (int argc, char *argv[])
if (!atril_thumbnail_pngenc_get (document, output, size)) {
g_object_unref (document);
ev_shutdown ();
+ g_strfreev (file_arguments);
+
return -2;
}
time_monitor_stop ();
g_object_unref (document);
ev_shutdown ();
+ g_strfreev (file_arguments);
return 0;
}