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;