On some systems, was seeing a failure at tests/cc/test_c_api.cc:172 due
to failure to open the /tmp/perf-pid.map file. Looking through the code,
narrowed it down to an invalid use of c_str() on a temporary
std::string. Fix it by storing the string in a variable.
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
static int child_func(void *arg) {
unsigned long long map_addr = (unsigned long long)arg;
- const char *path = perf_map_path(getpid()).c_str();
- FILE *file = fopen(path, "w");
+ string path = perf_map_path(getpid());
+ FILE *file = fopen(path.c_str(), "w");
if (file == NULL) {
return -1;
}
sleep(5);
- unlink(path);
+ unlink(path.c_str());
return 0;
}