mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-15 22:44:01 +00:00
Only widen string if necessary
This tried a bunch of times, but only the final one is important.
This commit is contained in:
parent
87b93cd4ca
commit
752b5362ee
1 changed files with 5 additions and 3 deletions
|
@ -511,16 +511,18 @@ bool env_universal_t::open_temporary_file(const wcstring &directory, wcstring *o
|
|||
int saved_errno;
|
||||
const wcstring tmp_name_template = directory + L"/fishd.tmp.XXXXXX";
|
||||
|
||||
char *narrow_str = nullptr;
|
||||
for (size_t attempt = 0; attempt < 10 && !success; attempt++) {
|
||||
char *narrow_str = wcs2str(tmp_name_template);
|
||||
narrow_str = wcs2str(tmp_name_template);
|
||||
int result_fd = fish_mkstemp_cloexec(narrow_str);
|
||||
saved_errno = errno;
|
||||
success = result_fd != -1;
|
||||
*out_fd = result_fd;
|
||||
*out_path = str2wcstring(narrow_str);
|
||||
free(narrow_str);
|
||||
}
|
||||
|
||||
*out_path = str2wcstring(narrow_str);
|
||||
free(narrow_str);
|
||||
|
||||
if (!success) {
|
||||
const char *error = std::strerror(saved_errno);
|
||||
debug(0, _(L"Unable to open temporary file '%ls': %s"), out_path->c_str(), error);
|
||||
|
|
Loading…
Reference in a new issue