From 10468068ac9d2d362a3b1ccbb12b7d6e4e759d9c Mon Sep 17 00:00:00 2001 From: Peter Howkins Date: Wed, 11 Apr 2018 02:07:55 +0100 Subject: [PATCH] dthelp: more coverity fixes --- cde/programs/dthelp/dthelpprint/PrintUtil.c | 1 + cde/programs/dthelp/parser/canon1/helptag/help.c | 5 ++++- cde/programs/dthelp/parser/canon1/helptag/xref.c | 1 + cde/programs/dthelp/parser/pass1/build/out.c | 3 ++- cde/programs/dthelp/parser/pass1/util/conutil.c | 3 ++- cde/programs/dthelp/parser/pass1/util/fclndir.c | 1 + cde/programs/dthelp/parser/pass2/eltdef/eltdef.c | 2 +- cde/programs/dthelp/parser/pass2/htag2/sdl.c | 2 +- cde/programs/dthelp/parser/pass2/util/entout.c | 3 +-- 9 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cde/programs/dthelp/dthelpprint/PrintUtil.c b/cde/programs/dthelp/dthelpprint/PrintUtil.c index 98b748dd..84125cb0 100644 --- a/cde/programs/dthelp/dthelpprint/PrintUtil.c +++ b/cde/programs/dthelp/dthelpprint/PrintUtil.c @@ -192,6 +192,7 @@ int _DtHPrGenFileOrPrint( if ( (status = system(printCommand))!= 0) { unlink(tmpfile); + free(tmpfile); return status; /* RETURN */ } diff --git a/cde/programs/dthelp/parser/canon1/helptag/help.c b/cde/programs/dthelp/parser/canon1/helptag/help.c index d1848be6..bd874c58 100644 --- a/cde/programs/dthelp/parser/canon1/helptag/help.c +++ b/cde/programs/dthelp/parser/canon1/helptag/help.c @@ -1610,6 +1610,7 @@ else { strcpy(pCharset, charset); mb_free(&charset); + free(charset); } else strcpy(pCharset, isoString); @@ -2809,7 +2810,7 @@ int tryleng = sizeof(pathbuf); int pathleng; int fileleng; SEARCH *thispath; -char *mb_inputname; +char *mb_inputname = NULL; M_WCHAR *wc_try, *wc_outputname; int tossfile; char filebuf[BIGBUF]; @@ -2876,6 +2877,8 @@ else } if (try != pathbuf) mb_free(&try); + +mb_free(&mb_inputname); } /* Below is a modified version of m_cyclent() that returns a pointer diff --git a/cde/programs/dthelp/parser/canon1/helptag/xref.c b/cde/programs/dthelp/parser/canon1/helptag/xref.c index 1a24f24f..ecd4df23 100644 --- a/cde/programs/dthelp/parser/canon1/helptag/xref.c +++ b/cde/programs/dthelp/parser/canon1/helptag/xref.c @@ -155,6 +155,7 @@ strcpy(helpext, ".xrh"); tex = fopen(helpbase, "w"); fprintf(tex, "\\gobble\001%s\002%%\n", m_signon); fputs("% Generated Cross-Reference Macros (for a particular document)\n", tex); +fclose(tex); if (! xtree.data) return; n = 0; diff --git a/cde/programs/dthelp/parser/pass1/build/out.c b/cde/programs/dthelp/parser/pass1/build/out.c index cb89f984..da478aa7 100644 --- a/cde/programs/dthelp/parser/pass1/build/out.c +++ b/cde/programs/dthelp/parser/pass1/build/out.c @@ -483,7 +483,7 @@ char *partype(n) void srefout(M_NOPAR) { LOGICAL first = TRUE ; - int *mapbysref ; + int *mapbysref = NULL; SREFSTRUCT *srefp ; SREFDATA *data ; int count = 0 ; @@ -544,6 +544,7 @@ void srefout(M_NOPAR) fputs(ndif, dtd) ; } SUBONE + free(mapbysref); } /* Output one element block in a template */ diff --git a/cde/programs/dthelp/parser/pass1/util/conutil.c b/cde/programs/dthelp/parser/pass1/util/conutil.c index 736e669a..abc32a94 100644 --- a/cde/programs/dthelp/parser/pass1/util/conutil.c +++ b/cde/programs/dthelp/parser/pass1/util/conutil.c @@ -424,8 +424,9 @@ if (loading) newdlm = (char **) calloc(trysize, sizeof(M_WCHAR *)); if (! newtransit || (loading && ! newdlm)) { trysize = NUMDELIM + 1; + free(newtransit); newtransit = (int *) calloc(NUMCON * trysize, sizeof(int)); - if (loading) newdlm = (char **) calloc(trysize, sizeof(M_WCHAR *)); + if (loading) { free(newdlm); newdlm = (char **) calloc(trysize, sizeof(M_WCHAR *)); } } if (! newtransit || (loading && ! newdlm)) { diff --git a/cde/programs/dthelp/parser/pass1/util/fclndir.c b/cde/programs/dthelp/parser/pass1/util/fclndir.c index 8edc6c6a..1d5a8859 100644 --- a/cde/programs/dthelp/parser/pass1/util/fclndir.c +++ b/cde/programs/dthelp/parser/pass1/util/fclndir.c @@ -144,6 +144,7 @@ void copyfile(pfile1,pfile2) ret = system(pcmd); ret = snprintf(pcmd, slen, "touch %s",pfile2); ret = system(pcmd); + free(pcmd); } int nextchar(file, data) diff --git a/cde/programs/dthelp/parser/pass2/eltdef/eltdef.c b/cde/programs/dthelp/parser/pass2/eltdef/eltdef.c index 20d28ec1..c89eeb81 100644 --- a/cde/programs/dthelp/parser/pass2/eltdef/eltdef.c +++ b/cde/programs/dthelp/parser/pass2/eltdef/eltdef.c @@ -75,7 +75,7 @@ int main(argc, argv) fprintf(stderr, "**** Specify interface file ****\n") ; exit(TRUE) ; } - strncpy(iffile, argv[1], IFLEN) ; + strncpy(iffile, argv[1], IFLEN - 1) ; initialize() ; while (TRUE) { m_token = scan() ; diff --git a/cde/programs/dthelp/parser/pass2/htag2/sdl.c b/cde/programs/dthelp/parser/pass2/htag2/sdl.c index b75adf6e..89821a0d 100644 --- a/cde/programs/dthelp/parser/pass2/htag2/sdl.c +++ b/cde/programs/dthelp/parser/pass2/htag2/sdl.c @@ -6395,7 +6395,7 @@ while (incr) * the amount of padding needed in between the vstruct and the first * virpage to make everything work */ -static int CompressVstruct() +static void CompressVstruct() { #define COMPRESS_PAD_LENGTH 10 char buffer[BUFSIZ], zTemp[4]; diff --git a/cde/programs/dthelp/parser/pass2/util/entout.c b/cde/programs/dthelp/parser/pass2/util/entout.c index 3f3420b7..433198c4 100644 --- a/cde/programs/dthelp/parser/pass2/util/entout.c +++ b/cde/programs/dthelp/parser/pass2/util/entout.c @@ -72,8 +72,7 @@ void entout(fname) int nameindex ; LOGICAL start ; - strncpy(efilename, fname, ENTFILENAME) ; - strncpy(&efilename[strlen(efilename)], ".h", 2) ; + snprintf(efilename, sizeof(efilename), "%s.h", fname); m_openchk(&entfile, efilename, "w") ; fprintf(entfile, "#include \"entdef.h\"\n") ; -- 2.25.1