diff options
author | okan <okan> | 2014-02-02 15:46:05 +0000 |
---|---|---|
committer | okan <okan> | 2014-02-02 15:46:05 +0000 |
commit | 0a71742af4f4b54cc1b2ea5efd5acfa2eb4113ba (patch) | |
tree | 7eba60868858b3578aeafbfe4ee604e59e910388 /conf.c | |
parent | fd827fd7578faae62b798c4b24f2aa6d80b7b7ce (diff) | |
download | cwm-0a71742af4f4b54cc1b2ea5efd5acfa2eb4113ba.tar.gz cwm-0a71742af4f4b54cc1b2ea5efd5acfa2eb4113ba.tar.xz cwm-0a71742af4f4b54cc1b2ea5efd5acfa2eb4113ba.zip |
The menu already limits entries with MENU_MAXENTRY, so don't bother
holding a command name limit as well.
Diffstat (limited to 'conf.c')
-rw-r--r-- | conf.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/conf.c b/conf.c index 0792bd7..4ab762f 100644 --- a/conf.c +++ b/conf.c @@ -51,13 +51,11 @@ conf_cmd_add(struct conf *c, const char *name, const char *path) sizeof(c->lockpath)) return (0); } else { - cmd = xmalloc(sizeof(*cmd)); - conf_cmd_remove(c, name); - if (strlcpy(cmd->name, name, sizeof(cmd->name)) >= - sizeof(cmd->name)) - return (0); + cmd = xmalloc(sizeof(*cmd)); + + cmd->name = xstrdup(name); if (strlcpy(cmd->path, path, sizeof(cmd->path)) >= sizeof(cmd->path)) return (0); @@ -74,6 +72,7 @@ conf_cmd_remove(struct conf *c, const char *name) TAILQ_FOREACH_SAFE(cmd, &c->cmdq, entry, cmdnxt) { if (strcmp(cmd->name, name) == 0) { TAILQ_REMOVE(&c->cmdq, cmd, entry); + free(cmd->name); free(cmd); } } @@ -291,6 +290,7 @@ conf_clear(struct conf *c) while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) { TAILQ_REMOVE(&c->cmdq, cmd, entry); + free(cmd->name); free(cmd); } |