From 52cd371306705c39ad8c06fef195f6c4cdebf664 Mon Sep 17 00:00:00 2001 From: Brenden Blanco Date: Fri, 8 Jul 2016 16:21:38 -0700 Subject: [PATCH] Fix test failure in test_libbcc (#603) 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 --- tests/cc/test_c_api.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/cc/test_c_api.cc b/tests/cc/test_c_api.cc index dae7aa9..4d290e6 100644 --- a/tests/cc/test_c_api.cc +++ b/tests/cc/test_c_api.cc @@ -123,8 +123,8 @@ static string perf_map_path(pid_t pid) { 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; } @@ -134,7 +134,7 @@ static int child_func(void *arg) { sleep(5); - unlink(path); + unlink(path.c_str()); return 0; } -- 2.7.4