This replaces the ERANGE retry loops with loops which have heap fallback. Heap allocation might actually be required for extremely large NSS results.