Avoid double free in case of corrupted files