Fixed segfault when requesting non-existant parent window
[rodin/chimara.git] / libchimara / window.c
index 84b6fd9431b4987b73e7832811d3b664e8418a3f..56cbd700e6d66f2a5d9b2f496073a18fcf91eb05 100644 (file)
@@ -37,7 +37,7 @@ window_new_common(glui32 rock)
        win->buffer = g_string_sized_new(1024);
 
        /* Initialise hyperlink table */
-       win->hyperlinks = g_hash_table_new_full(g_int_hash, g_direct_equal, g_free, g_object_unref);
+       win->hyperlinks = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free);
        
        return win;
 }
@@ -170,7 +170,11 @@ winid_t
 glk_window_get_parent(winid_t win)
 {
        VALID_WINDOW(win, return NULL);
+
        /* Value will also be NULL if win is the root window */
+       if(win->window_node->parent == NULL)
+               return NULL;
+
        return (winid_t)win->window_node->parent->data;
 }