Skip to content

Commit aaff953

Browse files
committed
Check if flag content does not exist
Before it was just assumed that the data exists, but as that would be accessing data after the array it mostly uses a nullpointer and with that causes a segmentation fault. This is being fixed with this change so that things like ./tau test.tau --max-iter don't cause a crash.
1 parent 05ebcd8 commit aaff953

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ int check_long(struct Arguments* arguments, const int argc, const char** const a
112112
exit(EXIT_SUCCESS);
113113
}
114114

115+
if(argc < 2) {
116+
fprintf(stderr, "\033[31mIf a flag is being used that contains data, the data should be provided.\033[0m\n");
117+
return 0;
118+
}
119+
115120
int second;
116121
if(str2int(&second, argv[1], 10) != STR2INT_SUCCESS) {
117122
fprintf(stderr, "\033[31mThe content of the flag has to be a number.\033[0m\n");

0 commit comments

Comments
 (0)