weston-launch: Add some error reporting for weston-launch

This also avoids us passing (size_t)(-1 * sizeof(gid_t)) into malloc
dev
Rob Bradford 12 years ago committed by Kristian Høgsberg
parent c9e64abc5c
commit 40be7b467f
  1. 7
      src/weston-launch.c

@ -84,11 +84,18 @@ read_groups(void)
gid_t *groups; gid_t *groups;
n = getgroups(0, NULL); n = getgroups(0, NULL);
if (n < 0) {
fprintf(stderr, "Unable to retrieve groups: %m\n");
return NULL;
}
groups = malloc(n * sizeof(gid_t)); groups = malloc(n * sizeof(gid_t));
if (!groups) if (!groups)
return NULL; return NULL;
if (getgroups(n, groups) < 0) { if (getgroups(n, groups) < 0) {
fprintf(stderr, "Unable to retrieve groups: %m\n");
free(groups); free(groups);
return NULL; return NULL;
} }

Loading…
Cancel
Save