From 83da6a028de4c4a3ea77816805cb6828bcf789c3 Mon Sep 17 00:00:00 2001 From: Ian Jones Date: Fri, 15 Oct 2021 00:19:23 +0100 Subject: [PATCH] Fixed one instance of warning re. the use of tmpnam in gui-dialogs.c and removed small duplication of free() in readPNG.c --- src/gui-dialogs.c | 7 ++++--- src/readPNG.c | 6 +----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/gui-dialogs.c b/src/gui-dialogs.c index b1ddae9..cec2de4 100644 --- a/src/gui-dialogs.c +++ b/src/gui-dialogs.c @@ -2705,6 +2705,7 @@ mo_status mo_edit_source(mo_window *win) { char *sourceFileName; FILE *fp; + int fd; int length; char *editorName; char execString[1024]; @@ -2748,10 +2749,10 @@ extern void AddChildProcessHandler(int, void (*)(), void *); /* write out source to tmp file with .html extension */ sourceFileName = malloc(255); - strcpy(sourceFileName, tmpnam(NULL)); - strcat(sourceFileName, ".html"); + strncpy(sourceFileName, "mosaic-XXXXXX.html\0", 19); + fd = mkstemps(sourceFileName, 5); - if (!(fp = fopen(sourceFileName,"w"))) + if (!(fp = fdopen(fd, "w"))) { char *buf, *final, tmpbuf[80]; int final_len; diff --git a/src/readPNG.c b/src/readPNG.c index 74b90e3..3c63457 100644 --- a/src/readPNG.c +++ b/src/readPNG.c @@ -383,8 +383,6 @@ ReadPNG(FILE *infile,int *width, int *height, XColor *colrs) q++; /* skip the alpha pixel */ } } - - free((char *)png_pixels); } else { @@ -400,11 +398,9 @@ ReadPNG(FILE *infile,int *width, int *height, XColor *colrs) *p++ = *q++; /*palette index*/ } } - - free((char *)png_pixels); - } + free((char *)png_pixels); free((png_byte **)row_pointers); /* clean up after the read, and free any memory allocated */