|
From: <sv...@va...> - 2014-09-28 21:14:12
|
Author: florian
Date: Sun Sep 28 22:14:05 2014
New Revision: 14586
Log:
A few tweaks:
Use VG_(strdup) instead of VG_(arena_strdup). Likewise for VG_(free).
Avoid memory leak in case ML_(find_executable) is called more than once
(which it currently is not).
Modified:
branches/BUF_REMOVAL/coregrind/m_initimg/initimg-pathscan.c
Modified: branches/BUF_REMOVAL/coregrind/m_initimg/initimg-pathscan.c
==============================================================================
--- branches/BUF_REMOVAL/coregrind/m_initimg/initimg-pathscan.c (original)
+++ branches/BUF_REMOVAL/coregrind/m_initimg/initimg-pathscan.c Sun Sep 28 22:14:05 2014
@@ -105,16 +105,13 @@
// matching non-executable we remember it but keep looking for an
// matching executable later in the path.
if (VG_(access)(buf, True/*r*/, False/*w*/, True/*x*/) == 0) {
- if (executable_name_out)
- VG_(arena_free)(VG_AR_CORE, executable_name_out);
- executable_name_out =
- VG_(arena_strdup)(VG_AR_CORE, "match_executable", buf);
+ VG_(free)(executable_name_out);
+ executable_name_out = VG_(strdup)("match_executable", buf);
return True; // Stop looking
} else if (VG_(access)(buf, True/*r*/, False/*w*/, False/*x*/) == 0
&& executable_name_out == NULL)
{
- executable_name_out =
- VG_(arena_strdup)(VG_AR_CORE, "match_executable", buf);
+ executable_name_out = VG_(strdup)("match_executable", buf);
return False; // Keep looking
} else {
return False; // Keep looking
@@ -137,6 +134,8 @@
// No '/' - we need to search the path
HChar* path = VG_(getenv)("PATH");
+ VG_(free)(executable_name_out);
+
executable_name_in = exec;
executable_name_out = NULL;
scan_colsep(path, match_executable);
|