X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftic.c;h=9ad79d47fb5773c8abef3aa9e033c0c488fe3eec;hp=6128e3301dd0e25786049451a01e655ca888a06f;hb=1c551ea75ea57f9186fbe8d79674ac85baa4d358;hpb=91fa4688e82518794fcf0c32a36f3fcca5e4c2d5 diff --git a/progs/tic.c b/progs/tic.c index 6128e330..9ad79d47 100644 --- a/progs/tic.c +++ b/progs/tic.c @@ -46,7 +46,7 @@ #include #include -MODULE_ID("$Id: tic.c,v 1.178 2012/10/27 19:57:21 tom Exp $") +MODULE_ID("$Id: tic.c,v 1.182 2012/12/16 00:03:12 tom Exp $") #define STDIN_NAME "" @@ -108,6 +108,8 @@ free_namelist(char **src) static void cleanup(void) { + int rc; + #if NO_LEAKS free_namelist(namelst); #endif @@ -115,10 +117,12 @@ cleanup(void) fclose(tmp_fp); if (to_remove != 0) { #if HAVE_REMOVE - remove(to_remove); + rc = remove(to_remove); #else - unlink(to_remove); + rc = unlink(to_remove); #endif + if (rc != 0) + perror(to_remove); } } @@ -376,9 +380,11 @@ open_tempfile(char *filename) _nc_STRCPY(filename, "/tmp/XXXXXX", PATH_MAX); #if HAVE_MKSTEMP { + int oldmask = umask(077); int fd = mkstemp(filename); if (fd >= 0) result = fdopen(fd, "w"); + umask(oldmask); } #else if (tmpnam(filename) != 0) @@ -546,7 +552,7 @@ matches(char **needle, const char *haystack) return (code); } -static const char * +static char * valid_db_path(const char *nominal) { struct stat sb; @@ -617,7 +623,7 @@ static void show_databases(const char *outdir) { bool specific = (outdir != 0) || getenv("TERMINFO") != 0; - const char *result; + char *result; const char *tried = 0; if (outdir == 0) { @@ -625,6 +631,7 @@ show_databases(const char *outdir) } if ((result = valid_db_path(outdir)) != 0) { printf("%s\n", result); + free(result); } else { tried = outdir; } @@ -632,6 +639,7 @@ show_databases(const char *outdir) if ((outdir = _nc_home_terminfo())) { if ((result = valid_db_path(outdir)) != 0) { printf("%s\n", result); + free(result); } else if (!specific) { tried = outdir; }