There's even more, read_dependency() also calls free_dependency() after calling read_identity() indirectly. I think it would be better reset the pointers in clear_identity(), to avoid reintroducing this bug.
Please also fix the title. This is a double free, not a memory leak.