Fixed one instance of warning re. the use of tmpnam in gui-dialogs.c and removed small duplication of free() in readPNG.c

master
Ian Jones 2021-10-15 00:19:23 +07:00 committed by Robert Clausecker
parent 2989d8e6ea
commit 83da6a028d
2 changed files with 5 additions and 8 deletions

@ -2705,6 +2705,7 @@ mo_status mo_edit_source(mo_window *win)
{ {
char *sourceFileName; char *sourceFileName;
FILE *fp; FILE *fp;
int fd;
int length; int length;
char *editorName; char *editorName;
char execString[1024]; char execString[1024];
@ -2748,10 +2749,10 @@ extern void AddChildProcessHandler(int, void (*)(), void *);
/* write out source to tmp file with .html extension */ /* write out source to tmp file with .html extension */
sourceFileName = malloc(255); sourceFileName = malloc(255);
strcpy(sourceFileName, tmpnam(NULL)); strncpy(sourceFileName, "mosaic-XXXXXX.html\0", 19);
strcat(sourceFileName, ".html"); fd = mkstemps(sourceFileName, 5);
if (!(fp = fopen(sourceFileName,"w"))) if (!(fp = fdopen(fd, "w")))
{ {
char *buf, *final, tmpbuf[80]; char *buf, *final, tmpbuf[80];
int final_len; int final_len;

@ -383,8 +383,6 @@ ReadPNG(FILE *infile,int *width, int *height, XColor *colrs)
q++; /* skip the alpha pixel */ q++; /* skip the alpha pixel */
} }
} }
free((char *)png_pixels);
} }
else { else {
@ -400,11 +398,9 @@ ReadPNG(FILE *infile,int *width, int *height, XColor *colrs)
*p++ = *q++; /*palette index*/ *p++ = *q++; /*palette index*/
} }
} }
free((char *)png_pixels);
} }
free((char *)png_pixels);
free((png_byte **)row_pointers); free((png_byte **)row_pointers);
/* clean up after the read, and free any memory allocated */ /* clean up after the read, and free any memory allocated */