lib: fix g_hash_table related read-after-free bug