lkml.org 
[lkml]   [2019]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 8/8] perf tools: Force perf_data__open|close zero data->file.path
Date
Making sure the data->file.path is zeroed on perf_data__open
error path and in perf_data__close, so we don't double free
it in case someone call it twice.

Link: http://lkml.kernel.org/n/tip-yt0yz1y9h5vdppsj8nkiuh07@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/data.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 7bd5ddeb7a41..e098e189f93e 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -237,7 +237,7 @@ static int open_file(struct perf_data *data)
open_file_read(data) : open_file_write(data);

if (fd < 0) {
- free(data->file.path);
+ zfree(&data->file.path);
return -1;
}

@@ -270,7 +270,7 @@ int perf_data__open(struct perf_data *data)

void perf_data__close(struct perf_data *data)
{
- free(data->file.path);
+ zfree(&data->file.path);
close(data->file.fd);
}

--
2.17.2
\
 
 \ /
  Last update: 2019-03-05 16:27    [W:0.061 / U:6.764 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site