diff options
author | okan | 2014-02-02 15:46:05 +0000 |
---|---|---|
committer | okan | 2014-02-02 15:46:05 +0000 |
commit | f66dedc8c6a186274d1dbc6220671401eba44b62 (patch) | |
tree | 5534751cdcb72960f956f6036133c4d0bb17ebb0 /conf.c | |
parent | 028326e24d7bb15a9c17b4c7e63a84b8b3af8c9c (diff) | |
download | cwm-f66dedc8c6a186274d1dbc6220671401eba44b62.tar.gz |
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 | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: conf.c,v 1.170 2014/01/30 22:17:22 okan Exp $ + * $OpenBSD: conf.c,v 1.171 2014/02/02 15:46:05 okan Exp $ */ #include <sys/param.h> @@ -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); } |