1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

libtt: resolve coverity issues related to double close()

This commit is contained in:
Peter Howkins 2018-04-12 00:04:13 +01:00
parent 680f79aac3
commit 91bb9a037a

View file

@ -75,7 +75,7 @@ isrepair(isfname, verbose)
{
extern char *rp_readrecord_v(), *rp_readrecord_f();
char cntlpg[ISCNTLSIZE];
int datfd, indfd, varfd;
int datfd = -1, indfd = -1, varfd = -1;
int minreclen, maxreclen;
int nrecords_fromcntl;
int varflag;
@ -225,9 +225,18 @@ isrepair(isfname, verbose)
/*
* Close all file descriptors.
*/
(void)close(datfd);
(void)close(indfd);
(void)close(varfd);
if(datfd != -1) {
close(datfd);
datfd = -1;
}
if(indfd != -1) {
close(indfd);
indfd = -1;
}
if(varfd != -1) {
close(varfd);
varfd = -1;
}
(void)isclose(isfd);
(void) sigfillset(&allsignals);
@ -304,9 +313,15 @@ isrepair(isfname, verbose)
ERROR:
(void)print("\007Didn't repair ISAM file '%s'\n", isfname);
(void)close(datfd);
(void)close(indfd);
(void)close(varfd);
if(datfd != -1) {
close(datfd);
}
if(indfd != -1) {
close(indfd);
}
if(varfd != -1) {
close(varfd);
}
(void)isclose(isfd);
if (namebuf != nameBuf) free(namebuf);
if (buffer != Buffer) free(buffer);