diff options
author | Joursoir <chat@joursoir.net> | 2021-06-12 19:41:16 +0000 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2021-06-12 19:41:40 +0000 |
commit | 2ee1a06f24895ea9067d9b026057581ff715aec8 (patch) | |
tree | 5f479b8fffe1dea7c29df65655b552ff9e2ae28f | |
parent | 1af9cbf7bb9e89fdc9de704c0b68209762ab8c80 (diff) | |
download | lock-password-2ee1a06f24895ea9067d9b026057581ff715aec8.tar.gz lock-password-2ee1a06f24895ea9067d9b026057581ff715aec8.tar.bz2 lock-password-2ee1a06f24895ea9067d9b026057581ff715aec8.zip |
lpass: delete side effect
-rw-r--r-- | src/lpass.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lpass.c b/src/lpass.c index 22e9eb8..d1ee817 100644 --- a/src/lpass.c +++ b/src/lpass.c @@ -46,6 +46,9 @@ static struct cmd_struct commands[] = { static struct cmd_struct *get_cmd(const char *name) { + if(!name) + return NULL; + struct cmd_struct *ptr; for(ptr = commands; ptr->cmd; ptr++) { if(strcmp(name, ptr->cmd) == 0) @@ -82,9 +85,8 @@ int main(int argc, char *argv[]) if(goto_maindir()) errprint_r(1, "%s", strerror(errno)); - char *cmd = (argv[1] != NULL) ? argv[1] : ""; - struct cmd_struct *ptr; - if((ptr = get_cmd(cmd))) + struct cmd_struct *ptr = get_cmd(argv[1]); + if(ptr) return ptr->func(argc, argv); return cmd_showtree(argc, argv); |