|
From: <sv...@va...> - 2013-09-30 18:36:43
|
Author: florian
Date: Mon Sep 30 18:36:31 2013
New Revision: 13589
Log:
Robustise the find_client function. Also fix a memory leak spotted by
IBM's BEAM checker.
Modified:
trunk/coregrind/launcher-linux.c
Modified: trunk/coregrind/launcher-linux.c
==============================================================================
--- trunk/coregrind/launcher-linux.c (original)
+++ trunk/coregrind/launcher-linux.c Mon Sep 30 18:36:31 2013
@@ -77,10 +77,14 @@
/* 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 @@
if (access(fullname, R_OK|X_OK) == 0)
return fullname;
}
+ free(fullname);
return clientname;
}
|