fix memleak in filename-only mode