From 22dec9316c1ed923a95a296a586abaf44df381cd Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 6 Feb 2009 17:34:36 -0800 Subject: [PATCH] Merge branch 'jk/pstat_getfile2' --- src/os/darwin/darwin_sigar.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 7856fdeb..9f0bb8ed 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -1983,6 +1983,7 @@ int sigar_file_system_list_get(sigar_t *sigar, fs = malloc(len); if ((num = sigar_getfsstat(fs, len, MNT_NOWAIT)) < 0) { + free(fs); return errno; } @@ -2026,6 +2027,7 @@ int sigar_file_system_list_get(sigar_t *sigar, sigar_fs_type_init(fsp); } + free(fs); return SIGAR_OK; } @@ -2445,8 +2447,10 @@ static int sigar_ifmsg_iter(sigar_t *sigar, ifmsg_iter_t *iter) case IFMSG_ITER_LIST: SIGAR_NET_IFLIST_GROW(iter->data.iflist); + /* sdl_data doesn't include a trailing \0, it is only sdl_nlen long */ name = malloc(sdl->sdl_nlen+1); - memcpy(name, sdl->sdl_data, sdl->sdl_nlen+1); + memcpy(name, sdl->sdl_data, sdl->sdl_nlen); + name[sdl->sdl_nlen] = '\0'; /* add the missing \0 */ iter->data.iflist->data[iter->data.iflist->number++] = name; break;