fixed mem leak in permute.cpp