From 3053e2430a134d82979a92a1578fbd97613c663f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 24 Aug 2014 00:16:31 +0200 Subject: m fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/setpgrp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setpgrp.c b/src/setpgrp.c index 976b10f..0f76ea9 100644 --- a/src/setpgrp.c +++ b/src/setpgrp.c @@ -61,12 +61,12 @@ int main(int argc, char* argv[]) goto fail; group = getpgrp(); - args = malloc((size_t)argc * sizeof(char*)); + args = malloc((size_t)(argc - off + 1) * sizeof(char*)); if (args == NULL) goto fail; memcpy(args, argv + off, (size_t)(argc - off) * sizeof(char*)); - args[argc - 1] = NULL; + args[argc - off] = NULL; if (switch_print) if (printf("%ji\n", (intmax_t)group) < 0) -- cgit v1.2.3-70-g09d2