[babl] catch babl_{format,model}_new calls with missing parameters



commit 1332d93c4d36d648f063ada4ae539ec66c1eeea5
Author: Nils Philippsen <nils redhat com>
Date:   Thu May 26 15:37:09 2011 +0200

    catch babl_{format,model}_new calls with missing parameters

 babl/babl-format.c |   14 ++++++++++++++
 babl/babl-model.c  |    7 +++++++
 2 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/babl/babl-format.c b/babl/babl-format.c
index 3760452..830d95f 100644
--- a/babl/babl-format.c
+++ b/babl/babl-format.c
@@ -384,6 +384,20 @@ babl_format_new (void *first_arg,
   if (!name)
     name = create_name (model, components, component, type);
 
+  if (!model)
+    {
+      babl_log ("no model specified for format '%s'", name);
+      babl_free(name);
+      return NULL;
+    }
+
+  if (!components)
+    {
+      babl_log ("no components specified for format '%s'", name);
+      babl_free(name);
+      return NULL;
+    }
+
   babl = babl_db_exist (db, id, name);
   if (id && !babl && babl_db_exist (db, 0, name))
     babl_fatal ("Trying to reregister BablFormat '%s' with different id!", name);
diff --git a/babl/babl-model.c b/babl/babl-model.c
index be2cdde..38bbfc3 100644
--- a/babl/babl-model.c
+++ b/babl/babl-model.c
@@ -183,6 +183,13 @@ babl_model_new (void *first_argument,
   else
     name = babl_model_create_name (components, component);
 
+  if (!components)
+    {
+      babl_log("no components specified for model '%s'", name);
+      babl_free(name);
+      return NULL;
+    }
+
   babl = babl_db_exist (db, id, name);
   if (id && !babl && babl_db_exist (db, 0, name))
     babl_fatal ("Trying to reregister BablModel '%s' with different id!", name);



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