From: Florian Krohm Date: Mon, 30 Sep 2013 18:36:31 +0000 (+0000) Subject: Robustise the find_client function. Also fix a memory leak spotted by X-Git-Tag: svn/VALGRIND_3_9_0~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb52f2212d08c3c6480e59c462ea260c00e57fe5;p=thirdparty%2Fvalgrind.git Robustise the find_client function. Also fix a memory leak spotted by IBM's BEAM checker. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13589 --- diff --git a/coregrind/launcher-linux.c b/coregrind/launcher-linux.c index 469380f25c..591bced3cc 100644 --- a/coregrind/launcher-linux.c +++ b/coregrind/launcher-linux.c @@ -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; }