tweaks: add an alias for a string variable, so the code makes more sense

master
Benno Schulenberg 2019-02-10 17:17:35 +01:00
parent 32d7d3900d
commit ea4ba3a150
1 changed files with 7 additions and 7 deletions

View File

@ -1421,7 +1421,7 @@ char *check_writable_directory(const char *path)
char *safe_tempfile(FILE **f) char *safe_tempfile(FILE **f)
{ {
const char *tmpdir_env = getenv("TMPDIR"); const char *tmpdir_env = getenv("TMPDIR");
char *full_tempdir = NULL; char *full_tempdir = NULL, *tempfile_name = NULL;
mode_t original_umask = 0; mode_t original_umask = 0;
int fd; int fd;
@ -1436,24 +1436,24 @@ char *safe_tempfile(FILE **f)
if (full_tempdir == NULL) if (full_tempdir == NULL)
full_tempdir = mallocstrcpy(NULL, "/tmp/"); full_tempdir = mallocstrcpy(NULL, "/tmp/");
full_tempdir = charealloc(full_tempdir, strlen(full_tempdir) + 12); tempfile_name = charealloc(full_tempdir, strlen(full_tempdir) + 12);
strcat(full_tempdir, "nano.XXXXXX"); strcat(tempfile_name, "nano.XXXXXX");
original_umask = umask(0); original_umask = umask(0);
umask(S_IRWXG | S_IRWXO); umask(S_IRWXG | S_IRWXO);
fd = mkstemp(full_tempdir); fd = mkstemp(tempfile_name);
if (fd != -1) if (fd != -1)
*f = fdopen(fd, "r+b"); *f = fdopen(fd, "r+b");
else { else {
free(full_tempdir); free(tempfile_name);
full_tempdir = NULL; tempfile_name = NULL;
} }
umask(original_umask); umask(original_umask);
return full_tempdir; return tempfile_name;
} }
#ifdef ENABLE_OPERATINGDIR #ifdef ENABLE_OPERATINGDIR