Fix warning and potential memleak.