fix small memleak in an error case