[gegl] gegl:load fix crash on loading non-existing paths
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl:load fix crash on loading non-existing paths
- Date: Sat, 16 Apr 2016 23:45:47 +0000 (UTC)
commit 90f4d1af13d884be330b8f8d74fbbbd07fdee46f
Author: Øyvind Kolås <pippin gimp org>
Date: Sun Apr 17 00:44:40 2016 +0100
gegl:load fix crash on loading non-existing paths
operations/core/load.c | 16 +++++++++++++---
tests/simple/test-serialize.c | 3 +++
2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/operations/core/load.c b/operations/core/load.c
index 3140ebf..60463f2 100644
--- a/operations/core/load.c
+++ b/operations/core/load.c
@@ -102,7 +102,9 @@ do_setup (GeglOperation *operation, const gchar *new_path, const gchar *new_uri)
resolved_path = realpath (new_path, NULL);
- if (!g_file_test (resolved_path, G_FILE_TEST_EXISTS))
+ if (resolved_path)
+ {
+ if (!g_file_test (resolved_path, G_FILE_TEST_EXISTS))
{
gchar *name = g_filename_display_name (resolved_path);
gchar *tmp = g_strdup_printf ("File '%s' does not exist", name);
@@ -116,7 +118,7 @@ do_setup (GeglOperation *operation, const gchar *new_path, const gchar *new_uri)
NULL);
g_free (tmp);
}
- else
+ else
{
if (extension)
handler = gegl_extension_handler_get_loader (extension);
@@ -127,7 +129,15 @@ do_setup (GeglOperation *operation, const gchar *new_path, const gchar *new_uri)
"path", resolved_path,
NULL);
}
- free (resolved_path);
+ free (resolved_path);
+ }
+ else
+ {
+ gegl_node_set (self->load,
+ "operation", "gegl:text",
+ "string", "load failed",
+ NULL);
+ }
}
else
{
diff --git a/tests/simple/test-serialize.c b/tests/simple/test-serialize.c
index 6d5abd6..df3631a 100644
--- a/tests/simple/test-serialize.c
+++ b/tests/simple/test-serialize.c
@@ -55,7 +55,10 @@ TestCase tests[] = {
#if 0
{"over aux=[]", " svg:src-over", "No such op 'gegl:['"}, /* should report error message */
#endif
+ {"over aux=[ load path=/ ]", " svg:src-over aux=[ gegl:load path='/' ]", ""},
{"inver", "", "No such op 'gegl:inver' suggestions: gegl:invert-gamma gegl:invert-linear"},
+
+ {"over aux=[ load path=/abc ]", " svg:src-over aux=[ gegl:load path='/abc' ]", ""},
{NULL, NULL}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]