[Chapel Merge] Issue error if mkdtemp fails

Branch: refs/heads/main
Revision: b450ccd
Author: aconsroe-hpe
Link: Unavailable
Log Message:

Merge pull request #18824 from aconsroe-hpe/fix/tmpdir-nullptr

Issue error if mkdtemp fails

reviewed by mppf

Issue error if mkdtemp fails

Previously, if mkdtemp failed to create the directory requested, it
returns NULL which got propagated up, resulting in a segfault when it
tried to be used.

This change checks the return value and issues a fatal error instead.

Also dup'ing the return value of astr because we shouldn't be
modifying it.

Thanks to mppf for the suggestion on using a second astr

Closes Cray/chapel-private#2816

Tested with TMPDIR=notadir chpl examples/hello.chpl

Modified Files:
M compiler/util/files.cpp

Compare: https://github.com/chapel-lang/chapel/compare/a59d902eb098...b450ccd69202