Commit 6e34bb5f authored by Philippe Gerum's avatar Philippe Gerum

boilerplate/setup: ensure that argv[argc] is allocated and NULL

The copy of the argument vector we build for preprocessing Xenomai
options must have argc + 1 cells, with argv[argc] set to NULL [1].

See http://xenomai.org/pipermail/xenomai/2018-March/038593.html.

[1] https://www.gnu.org/software/libc/manual/html_node/Program-Arguments.html
parent 1673cc2b
......@@ -237,7 +237,7 @@ static inline char **prep_args(int argc, char *const argv[])
char **uargv;
int n;
uargv = malloc(argc * sizeof(char *));
uargv = malloc((argc + 1) * sizeof(char *));
if (uargv == NULL)
return NULL;
......@@ -247,6 +247,8 @@ static inline char **prep_args(int argc, char *const argv[])
return NULL;
}
uargv[argc] = NULL;
return uargv;
}
......@@ -261,6 +263,7 @@ static inline void pack_args(int *argcp, char **argv)
free(argv[in]);
}
argv[out] = NULL;
*argcp = out;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment