Commit 01fd555e authored by Guillaume Roguez's avatar Guillaume Roguez

main: fix infinite loop in arguments parsing

Refs #65931

Change-Id: I1753fc6bf9206325c97303d535ba1e2795c823b4
parent 4518e7e6
......@@ -85,7 +85,13 @@ parse_args(int argc, char *argv[], bool& persistent)
/* getopt_long stores the option index here. */
int option_index = 0;
switch (getopt_long(argc, argv, "dcphv", long_options, &option_index)) {
auto c = getopt_long(argc, argv, "dcphv", long_options, &option_index);
// end of the options
if (c == -1)
break;
switch (c) {
case 'd':
debugFlag = true;
break;
......@@ -107,7 +113,6 @@ parse_args(int argc, char *argv[], bool& persistent)
versionFlag = true;
break;
case -1: // end of the options
default:
break;
}
......
......@@ -90,7 +90,13 @@ parse_args(int argc, char *argv[], bool& persistent)
/* getopt_long stores the option index here. */
int option_index = 0;
switch (getopt_long(argc, argv, "dcphv", long_options, &option_index)) {
auto c = getopt_long(argc, argv, "dcphv", long_options, &option_index);
// end of the options
if (c == -1)
break;
switch (c) {
case 'd':
debugFlag = true;
break;
......@@ -112,7 +118,6 @@ parse_args(int argc, char *argv[], bool& persistent)
versionFlag = true;
break;
case -1: // end of the options
default:
break;
}
......
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