aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/sort.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 7ad62393aa88..83336610faa9 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -249,7 +249,7 @@ static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf,
249 size_t size, 249 size_t size,
250 unsigned int width __maybe_unused) 250 unsigned int width __maybe_unused)
251{ 251{
252 FILE *fp; 252 FILE *fp = NULL;
253 char cmd[PATH_MAX + 2], *path = self->srcline, *nl; 253 char cmd[PATH_MAX + 2], *path = self->srcline, *nl;
254 size_t line_len; 254 size_t line_len;
255 255
@@ -270,7 +270,6 @@ static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf,
270 270
271 if (getline(&path, &line_len, fp) < 0 || !line_len) 271 if (getline(&path, &line_len, fp) < 0 || !line_len)
272 goto out_ip; 272 goto out_ip;
273 fclose(fp);
274 self->srcline = strdup(path); 273 self->srcline = strdup(path);
275 if (self->srcline == NULL) 274 if (self->srcline == NULL)
276 goto out_ip; 275 goto out_ip;
@@ -280,8 +279,12 @@ static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf,
280 *nl = '\0'; 279 *nl = '\0';
281 path = self->srcline; 280 path = self->srcline;
282out_path: 281out_path:
282 if (fp)
283 pclose(fp);
283 return repsep_snprintf(bf, size, "%s", path); 284 return repsep_snprintf(bf, size, "%s", path);
284out_ip: 285out_ip:
286 if (fp)
287 pclose(fp);
285 return repsep_snprintf(bf, size, "%-#*llx", BITS_PER_LONG / 4, self->ip); 288 return repsep_snprintf(bf, size, "%-#*llx", BITS_PER_LONG / 4, self->ip);
286} 289}
287 290