free_semiring: fix a memory leak