[gegl] operations: matting-global with no foreground/background information must fail.



commit 73b49ddc6950b85a4577afc9a54b5c2e33c20db4
Author: Jehan <jehan girinstud io>
Date:   Sat Apr 19 12:02:29 2014 +1200

    operations: matting-global with no foreground/background information must fail.

 operations/common/matting-global.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/operations/common/matting-global.c b/operations/common/matting-global.c
index b0a68dd..332634f 100644
--- a/operations/common/matting-global.c
+++ b/operations/common/matting-global.c
@@ -370,6 +370,14 @@ matting_process (GeglOperation       *operation,
         }
     }
 
+  /* If we have no information to work with, there is nothing to process. */
+  if (foreground_samples->len == 0 ||
+      background_samples->len == 0)
+    {
+      success = FALSE;
+      goto cleanup;
+    }
+
   // Initialize unknowns
   for (y = 0; y < h; y++)
     {
@@ -449,7 +457,7 @@ matting_process (GeglOperation       *operation,
                    GEGL_AUTO_ROWSTRIDE);
   success = TRUE;
 
-  // Free memory
+cleanup:
   g_free (input);
   g_free (trimap);
   g_free (output);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]