summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
Diffstat (limited to 'compat')
-rw-r--r--compat/linux/procinfo.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/compat/linux/procinfo.c b/compat/linux/procinfo.c
index 62f8aaed4c..bd01f017bc 100644
--- a/compat/linux/procinfo.c
+++ b/compat/linux/procinfo.c
@@ -18,12 +18,14 @@ static void get_ancestry_names(struct strvec *names)
/* try to use procfs if it's present. */
strbuf_addf(&procfs_path, "/proc/%d/comm", getppid());
- if (strbuf_read_file(&name, procfs_path.buf, 0)) {
- strbuf_release(&procfs_path);
+ if (strbuf_read_file(&name, procfs_path.buf, 0) > 0) {
strbuf_trim_trailing_newline(&name);
- strvec_push(names, strbuf_detach(&name, NULL));
+ strvec_push(names, name.buf);
}
+ strbuf_release(&procfs_path);
+ strbuf_release(&name);
+
return;
}