add free() before raise error