Copy result of setlocale(..., NULL)

...since it points to an internal buffer that is freed upon the subsequent setlocale(..., "C") call.

Bug discovered by @dbussink using Valgrind.