fix abort() on invalid cookie (illegal free)