dthelp/helpgen.c: coverity CID 175085; use after free
authorJon Trulson <jon@radscan.com>
Sun, 1 Apr 2018 00:21:14 +0000 (18:21 -0600)
committerJon Trulson <jon@radscan.com>
Sun, 1 Apr 2018 00:21:14 +0000 (18:21 -0600)
cde/programs/dthelp/dthelpgen/helpgen.c

index 69f2686437cd1559449410aa7a0a0867b5a306b3..1ce60bc36cb66f7536900f5b7b27ed6b4212b198 100644 (file)
@@ -384,7 +384,7 @@ CreateFamily (
     char       *title = NULL;
     char       *abstract = NULL;
     char       *list = NULL;
-    char       *token;
+    char       *token = NULL;
     char       *ptr;
     char       *bitmap = NULL;
     char        familyName [20];       /* FAMILY%d */
@@ -501,8 +501,11 @@ CreateFamily (
                                CreateVolumeLink (canvas,out_topic, token) == 0)
                    count++;
 
-               if (token && *token != '\0' && *token != '\n')
+               if (token)
+                {
                    free ((void *) token);
+                    token = NULL;
+                }
 
              } while (list && *list != '\0');
 
@@ -579,8 +582,7 @@ CreateFamily (
          }
        XrmDestroyDatabase (db);
       }
-      
-    free (token);
+
     return result;
 }