gproject: Get rid of some memory leaks

Thanks to Pavel Roschin.