fix potential memory leak when invalid line is skipped