dthelp: more coverity fixes
authorPeter Howkins <flibble@users.sf.net>
Wed, 11 Apr 2018 01:07:55 +0000 (02:07 +0100)
committerPeter Howkins <flibble@users.sf.net>
Wed, 11 Apr 2018 01:07:55 +0000 (02:07 +0100)
cde/programs/dthelp/dthelpprint/PrintUtil.c
cde/programs/dthelp/parser/canon1/helptag/help.c
cde/programs/dthelp/parser/canon1/helptag/xref.c
cde/programs/dthelp/parser/pass1/build/out.c
cde/programs/dthelp/parser/pass1/util/conutil.c
cde/programs/dthelp/parser/pass1/util/fclndir.c
cde/programs/dthelp/parser/pass2/eltdef/eltdef.c
cde/programs/dthelp/parser/pass2/htag2/sdl.c
cde/programs/dthelp/parser/pass2/util/entout.c

index 98b748dd8880854b1b6db08518c86cc6b47f34ba..84125cb06045e999585e5709d0d8a0bc1bb9d239 100644 (file)
@@ -192,6 +192,7 @@ int _DtHPrGenFileOrPrint(
    if ( (status = system(printCommand))!= 0)
    {
       unlink(tmpfile);
+      free(tmpfile);
       return status;                           /* RETURN */
    }
 
index d1848be6a57719ffbd246a428d6a25290ba52dda..bd874c58a3094282a5a2ab79f9c2b26f1548d7e2 100644 (file)
@@ -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
index 1a24f24f9d1efe5638de78e49dbd96df98f441f6..ecd4df23276553a2f929870d27c4bbc1de563b55 100644 (file)
@@ -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;
index cb89f98481c0f6d0163b39e41459127a9be1d27f..da478aa73d2a8bf8e7c016a4425020c3bc5a3971 100644 (file)
@@ -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 */
index 736e669a1882f25a2cb7d9153f5717805f9eb0e9..abc32a94182024b3bf6284690d158ee4e9e792d9 100644 (file)
@@ -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))
     {
index 8edc6c6adefe269012e30802d956c25deb82d76a..1d5a88591f3778cf058607e3c358fb53793f5405 100644 (file)
@@ -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)
index 20d28ec1dce4774c49df9eecfb7e61ddca87365d..c89eeb8148837013eaf7665479b87f694bafe4b7 100644 (file)
@@ -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() ;
index b75adf6eb668fb1b3995908cafe5cf5ad331c13e..89821a0d5a210417d14d315f98537035d9f72513 100644 (file)
@@ -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];
index 3f3420b77e44ea3e48aa5454feb90e7c961a48a9..433198c4a1b4a173df1e6a257ae0081074924697 100644 (file)
@@ -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") ;