From 3d2b2676e3fc0a5b243b8a4188d07bba1b4b40a4 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 16 Feb 2013 18:40:39 +0100 Subject: Fix `getgroups' for when zero supplementary group IDs exist. * libguile/posix.c (scm_getgroups): Return the empty vector when NGROUPS is zero. Reported by Mike Gran . --- libguile/posix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libguile/posix.c') diff --git a/libguile/posix.c b/libguile/posix.c index 324f21b78..39661a0f6 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -265,8 +265,10 @@ SCM_DEFINE (scm_getgroups, "getgroups", 0, 0, 0, GETGROUPS_T *groups; ngroups = getgroups (0, NULL); - if (ngroups <= 0) + if (ngroups < 0) SCM_SYSERROR; + else if (ngroups == 0) + return scm_c_make_vector (0, SCM_BOOL_F); size = ngroups * sizeof (GETGROUPS_T); groups = scm_malloc (size); -- cgit v1.2.3