From 6c70a2a97819a4686bb3bbc1c60aea0e70dd3b30 Mon Sep 17 00:00:00 2001 From: piotras Date: Fri, 9 Sep 2011 13:53:33 +0200 Subject: [PATCH] Check if given classname exists in GType system. Refs gh-120 --- src/midgard_schema_object_factory.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/midgard_schema_object_factory.c b/src/midgard_schema_object_factory.c index 6c2afdc6..476a02bc 100644 --- a/src/midgard_schema_object_factory.c +++ b/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;