upkg: Add some error checking around upkg_export_get_class.
authorNick Bowler <nbowler@draconx.ca>
Sun, 20 May 2012 17:29:44 +0000 (13:29 -0400)
committerNick Bowler <nbowler@draconx.ca>
Sun, 20 May 2012 17:29:44 +0000 (13:29 -0400)
This avoids a segfault when it fails.

src/uobject/uobject.c
src/upkg.c

index 627abe68e32ac3dc2405a1887fd3ad85178e4d10..331b8ae096a487673e48da8ac66ed9808ececeda 100644 (file)
@@ -529,6 +529,8 @@ GObject *u_object_new_from_package(GTypeModule *pkg, unsigned long idx)
        GType type;
 
        class = upkg_export_class(U_PKG(pkg)->pkg, idx, &package);
+       if (!class)
+               return NULL;
 
        type = u_object_module_get_class(package, class);
        if (type) {
index ee1023a28cc3c33a80f0af410130b12976822816..50f5ddab8491cab0787dd53f12025b2dbd8008e6 100644 (file)
@@ -366,7 +366,10 @@ static int object_info(GTypeModule *pkg, unsigned long idx)
        export_print_fullname(pkg, export);
 
        class = upkg_export_class(upkg, idx, &package);
-       printf(" (%s.%s)\n", package, class);
+       if (class)
+               printf(" (%s.%s)\n", package, class);
+       else
+               printf(" (failed to get class)\n");
 
        if (verbose >= 1 && object_dump_properties(pkg, idx) != 0)
                ret = -1;