Permalink
Browse files

Check if given classname exists in GType system. Refs gh-120

  • Loading branch information...
1 parent 4b66acc commit 6c70a2a97819a4686bb3bbc1c60aea0e70dd3b30 @piotras piotras committed Sep 9, 2011
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/midgard_schema_object_factory.c
View
8 src/midgard_schema_object_factory.c
@@ -205,6 +205,14 @@ midgard_schema_object_factory_get_object_by_path (MidgardConnection *mgd, const
g_return_val_if_fail (classname != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
+ GType class_type = g_type_from_name (classname);
+ if (class_type == G_TYPE_INVALID
+ || !g_type_is_a (class_type, MIDGARD_TYPE_DBOBJECT)) {
+ g_warning ("Invalid '%s' classname. Expected MidgardDBObject derived one");
+ /* TODO, add error */
+ return NULL;
+ }
+
MIDGARD_ERRNO_SET(mgd, MGD_ERR_OK);
gchar *object_path = NULL;

0 comments on commit 6c70a2a

Please sign in to comment.