libDtHelp: Cov 88275
authorPeter Howkins <flibble@users.sf.net>
Sat, 11 Aug 2018 00:08:17 +0000 (01:08 +0100)
committerPeter Howkins <flibble@users.sf.net>
Sat, 11 Aug 2018 00:08:17 +0000 (01:08 +0100)
cde/lib/DtHelp/Environ_c.c

index 516278db7306759a6a907f80ca54f7ea458bfd9b..3e7990238353fb2fbacb877c1d372e9cb41be1b6 100644 (file)
@@ -74,6 +74,7 @@ char * _DtCliSrvGetDtUserSession(void)
       char   screen[BUFSIZ];
       char * display = NULL;
       char * localDisplayVar = getenv("DISPLAY");
+      int needsfree = 0;
 
       if (localDisplayVar == NULL) {
 
@@ -98,6 +99,7 @@ char * _DtCliSrvGetDtUserSession(void)
       }
       else {
        display = malloc(strlen(localDisplayVar) + 1);
+       needsfree = 1;
        strcpy(display, localDisplayVar);
       }
          
@@ -120,6 +122,10 @@ char * _DtCliSrvGetDtUserSession(void)
       if (envVar)
        sprintf (envVar, "%s-%s-%s", logname, display, screen);
 
+      if(needsfree) {
+        free(display);
+      }
+
       return envVar;
     }
   }