fixed memory leak in glist_write