]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Robustise the find_client function. Also fix a memory leak spotted by
authorFlorian Krohm <florian@eich-krohm.de>
Mon, 30 Sep 2013 18:36:31 +0000 (18:36 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Mon, 30 Sep 2013 18:36:31 +0000 (18:36 +0000)
IBM's BEAM checker.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13589

coregrind/launcher-linux.c

index 469380f25c3780ffd5ee4983d2121ead59785156..591bced3cc0bb5772c29e5f0fd9d5a8d22311e09 100644 (file)
@@ -77,10 +77,14 @@ static void barf ( const char *format, ... )
 /* Search the path for the client program */
 static const char *find_client(const char *clientname)
 {
-   char *fullname = NULL;
+   char *fullname;
    const char *path = getenv("PATH");
    const char *colon;
 
+   assert(clientname != NULL);
+
+   if (path == NULL) return clientname;
+
    /* Make the size of the FULLNAME buffer large enough. */
    unsigned need = strlen(path) + strlen("/") + strlen(clientname) + 1;
 
@@ -108,6 +112,7 @@ static const char *find_client(const char *clientname)
       if (access(fullname, R_OK|X_OK) == 0)
          return fullname;
    }
+   free(fullname);
 
    return clientname;
 }