From d51f3e34b4b9aecb62fa3ecaca9d0ac298ef511c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 11 Jan 2012 18:14:18 +0000 Subject: complete the do-not-free-data-from-getmntinfo() fix git-svn-id: svn://localhost/ardour2/branches/3.0@11232 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/pbd/mountpoint.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'libs/pbd/mountpoint.cc') diff --git a/libs/pbd/mountpoint.cc b/libs/pbd/mountpoint.cc index 045e815282..46cea42e0a 100644 --- a/libs/pbd/mountpoint.cc +++ b/libs/pbd/mountpoint.cc @@ -110,8 +110,13 @@ mountpoint (string path) const char *cpath = path.c_str(); char best[PATH_MAX+1]; + /* From the manpage, under "BUGS" : "The memory allocated by getmntinfo() cannot be free(3)'d by the + application." + + Thus: we do NOT try to free memory allocated by getmntinfo() + */ + if ((count = getmntinfo(&mntbufp, MNT_NOWAIT)) == 0) { - free(mntbufp); return "\0"; } @@ -135,7 +140,6 @@ mountpoint (string path) if (cpath[matchlen] == '\0') { snprintf(best, sizeof(best), "%s", mntbufp[i].f_mntonname); - free(mntbufp); return best; } else { @@ -146,12 +150,6 @@ mountpoint (string path) } } } - - /* From the manpage, under "BUGS" : "The memory allocated by getmntinfo() cannot be free(3)'d by the - application." - - free(mntbufp); - */ return best; } -- cgit v1.2.3