[gegl] magick-load: use more robust g_spawn_async() instead of system()
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] magick-load: use more robust g_spawn_async() instead of system()
- Date: Wed, 15 Dec 2021 23:14:16 +0000 (UTC)
commit bfce470f0f2f37968862129d5038b35429f2909b
Author: Øyvind Kolås <pippin gimp org>
Date: Thu Dec 16 00:10:24 2021 +0100
magick-load: use more robust g_spawn_async() instead of system()
This fixes issue #298 by avoiding the shell parsing being invoked at
all, this less brittle than any forms of escaping characters, while
retaining the ability to address all existing files.
operations/common/magick-load.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/operations/common/magick-load.c b/operations/common/magick-load.c
index e2055b2e9..595169115 100644
--- a/operations/common/magick-load.c
+++ b/operations/common/magick-load.c
@@ -41,20 +41,23 @@ load_cache (GeglProperties *op_magick_load)
if (!op_magick_load->user_data)
{
gchar *filename;
- gchar *cmd;
GeglNode *graph, *sink, *loader;
GeglBuffer *newbuf = NULL;
/* ImageMagick backed fallback FIXME: make this robust.
* maybe use pipes in a manner similar to the raw loader,
* or at least use a properly unique filename */
+ char *argv[4] = {"convert", NULL, NULL, NULL};
filename = g_build_filename (g_get_tmp_dir (), "gegl-magick.png", NULL);
- cmd = g_strdup_printf ("convert \"%s\"'[0]' \"%s\"",
- op_magick_load->path, filename);
- if (system (cmd) == -1)
+
+ argv[1] = g_strdup_printf ("%s[0]", op_magick_load->path);
+ argv[2] = filename;
+ if (!g_spawn_sync (NULL, argv, NULL, G_SPAWN_DEFAULT,
+ NULL, NULL, NULL, NULL, NULL, NULL))
g_warning ("Error executing ImageMagick convert program");
+ g_free (argv[1]);
graph = gegl_node_new ();
sink = gegl_node_new_child (graph,
@@ -67,7 +70,6 @@ load_cache (GeglProperties *op_magick_load)
gegl_node_process (sink);
op_magick_load->user_data = (gpointer) newbuf;
g_object_unref (graph);
- g_free (cmd);
g_free (filename);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]