I said most of the pid_to_exec_file target_ops method for some platforms will
allocate memory for exec_file and add them to cleanup.
But some of them didn't do that.
So I make a patch to fix this memleak.
Thanks,
Hui
2014-03-17 Hui Zhu <hui@codesourcery.com>
* fbsd-nat.c (fbsd_pid_to_exec_file): Add make_cleanup.
* nbsd-nat.c (nbsd_pid_to_exec_file): Ditto.
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -43,6 +43,8 @@ fbsd_pid_to_exec_file (struct target_ops
char *buf = xcalloc (len, sizeof (char));
char *path;
+ make_cleanup (xfree, buf);
+
#ifdef KERN_PROC_PATHNAME
int mib[4];
--- a/gdb/nbsd-nat.c
+++ b/gdb/nbsd-nat.c
@@ -31,6 +31,8 @@ nbsd_pid_to_exec_file (struct target_ops
char *buf = xcalloc (len, sizeof (char));
char *path;
+ make_cleanup (xfree, buf);
+
path = xstrprintf ("/proc/%d/exe", pid);
if (readlink (path, buf, PATH_MAX - 1) == -1)
{