c_glib: fix some leak and segfault