Paths >128 chars could crash. Replace BLI_newname with direct BLI_stringenc/dec use which makes more sense in this case.