Skip to content

Commit

Permalink
Fix optind beyond argc
Browse files Browse the repository at this point in the history
Signed-off-by: Rongwei Wang <[email protected]>
  • Loading branch information
wangrongwei committed Jul 17, 2021
1 parent 2979b73 commit 12dc16d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions kread.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ static void init(int argc, char *argv[])
ptedump_enabled = 1;
/* FIXME: pid1,pid2,pid3 */
target_pid = (pid_t)strtoul(optarg, NULL, 0);
target_addr = htol(argv[optind], RETURN_ON_ERROR, NULL);
if (argc - 1 >= optind)
target_addr = htol(argv[optind], RETURN_ON_ERROR, NULL);
break;
case 'P':
/* TODO */
Expand All @@ -193,7 +194,9 @@ static void init(int argc, char *argv[])
}

/* env */
kr_debug = strtol(getenv("KR_DEBUG"), NULL, 0);
char *env = getenv("KR_DEBUG");
if (env != NULL)
kr_debug = strtol(env, NULL, 0);
signal(SIGSEGV, signal_handler);
signal(SIGABRT, signal_handler);
}
Expand Down

0 comments on commit 12dc16d

Please sign in to comment.