Skip to content
Snippets Groups Projects
Commit 092b4ca5 authored by Scott Lobdell's avatar Scott Lobdell
Browse files

Merge QP1A.190228.005

Change-Id: I9c747075495b86a1f2418c608820ba3d4dedbb5f
parents 3f3ba1fc db296b2c
No related branches found
No related tags found
No related merge requests found
...@@ -29,8 +29,10 @@ poptContext poptGetContext(const char *name, int argc, const char **argv, ...@@ -29,8 +29,10 @@ poptContext poptGetContext(const char *name, int argc, const char **argv,
for (; options[count].longName; count++) { for (; options[count].longName; count++) {
} }
// getopt_long expects the last element to be null
// so allocate count + 1
struct option *long_options = (struct option *) struct option *long_options = (struct option *)
calloc(count, sizeof(struct option)); calloc(count + 1, sizeof(struct option));
for (int i = 0; options[i].longName; i++) { for (int i = 0; options[i].longName; i++) {
long_options[i].name = options[i].longName; long_options[i].name = options[i].longName;
long_options[i].flag = 0; long_options[i].flag = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment