Check strdup() failure

This commit is contained in:
Unto Sten 2019-05-10 20:53:04 +03:00 committed by William Roberts
parent cd1ef4d64e
commit baf8a1de16

View File

@ -27,6 +27,11 @@ int main(int argc, char **argv)
switch (opt) {
case 'l':
level = strdup(optarg);
if (!level) {
fprintf(stderr, "memory allocation failure: %d(%s)\n",
errno, strerror(errno));
return 3;
}
break;
default:
usage(argv[0], "invalid option", 1);