Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail early if argc <= 0 or argv[0] is NULL
Under musl optind will be 1 if getopt is called with argc == 0. Under glibc it is not quite clear what will happen and I haven't tested it. In either case, this triggers a bug where argv ends up pointing at envp and argc is set to -1 which has further unclear implications on the execution of the program. By failing early, these issues can be safely avoided. fputs and exit are used instead of errx as errx does not have the information necessary to print a meaningful program name.
- Loading branch information