Free metadata if already allocated; fixes a memleak if the header occurs twice