[gimp] libgimpbase: don't allow parasites with zero-length names



commit 245106f32099ad9b144a59d7ee820c5a6a1ddb4c
Author: Michael Natterer <mitch gimp org>
Date:   Mon Mar 17 09:34:56 2014 +0100

    libgimpbase: don't allow parasites with zero-length names
    
    Check in gimp_parasite_new() and fail GValue validation for parasites
    with empty name. So far we only disallowed NULL names, this change
    forbids the empty string "" too.

 libgimpbase/gimpparasite.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/libgimpbase/gimpparasite.c b/libgimpbase/gimpparasite.c
index d8ab67d..01f8300 100644
--- a/libgimpbase/gimpparasite.c
+++ b/libgimpbase/gimpparasite.c
@@ -140,6 +140,7 @@ gimp_param_parasite_validate (GParamSpec *pspec,
       return TRUE;
     }
   else if (parasite->name == NULL                          ||
+           *parasite->name == '\0'                         ||
            ! g_utf8_validate (parasite->name, -1, NULL)    ||
            (parasite->size == 0 && parasite->data != NULL) ||
            (parasite->size >  0 && parasite->data == NULL))
@@ -216,7 +217,7 @@ gimp_parasite_new (const gchar    *name,
 {
   GimpParasite *parasite;
 
-  if (!name)
+  if (! (name && *name))
     return NULL;
 
   parasite = g_slice_new (GimpParasite);


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