summaryrefslogtreecommitdiff
path: root/src/common/console.c
diff options
context:
space:
mode:
authorKenpachi2k13 <3476227+Kenpachi2k13@users.noreply.github.com>2020-05-05 01:00:27 +0200
committerGitHub <noreply@github.com>2020-05-05 01:00:27 +0200
commit66607bfbfe197a5fec86dd1efe34a2da80929648 (patch)
treeed0e97ddc134c82067a436ea3ffd67f2f46be60b /src/common/console.c
parent3f6b7497531f9ace331ca74d271898e938245c04 (diff)
parent944d8489f1bcca93e6b2ff06a159084f064dce12 (diff)
downloadhercules-66607bfbfe197a5fec86dd1efe34a2da80929648.tar.gz
hercules-66607bfbfe197a5fec86dd1efe34a2da80929648.tar.bz2
hercules-66607bfbfe197a5fec86dd1efe34a2da80929648.tar.xz
hercules-66607bfbfe197a5fec86dd1efe34a2da80929648.zip
Merge branch 'master' into configure_newopt
Diffstat (limited to 'src/common/console.c')
-rw-r--r--src/common/console.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/common/console.c b/src/common/console.c
index a990d86b3..5b4dbeb1a 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -2,8 +2,8 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2018 Hercules Dev Team
- * Copyright (C) Athena Dev Teams
+ * Copyright (C) 2012-2020 Hercules Dev Team
+ * Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -322,6 +322,7 @@ static void console_parse_create(char *name, CParseFunc func)
nullpo_retv(name);
safestrncpy(sublist, name, CP_CMD_LENGTH * 5);
tok = strtok(sublist,":");
+ nullpo_retv(tok);
ARR_FIND(0, VECTOR_LENGTH(console->input->command_list), i, strcmpi(tok, VECTOR_INDEX(console->input->command_list, i)->cmd) == 0);
@@ -404,6 +405,10 @@ static void console_parse_sub(char *line)
nullpo_retv(line);
memcpy(bline, line, 200);
tok = strtok(line, " ");
+ if (tok == NULL) {
+ // Ignore empty commands
+ return;
+ }
ARR_FIND(0, VECTOR_LENGTH(console->input->command_list), i, strcmpi(tok, VECTOR_INDEX(console->input->command_list, i)->cmd) == 0);
if (i == VECTOR_LENGTH(console->input->command_list)) {
@@ -417,6 +422,12 @@ static void console_parse_sub(char *line)
if (cmd->type == CPET_FUNCTION) {
tok = strtok(NULL, "");
+ if (tok != NULL) {
+ while (tok[0] == ' ')
+ tok++;
+ if (tok[0] == '\0')
+ tok = NULL;
+ }
cmd->u.func(tok);
return;
}
@@ -444,6 +455,12 @@ static void console_parse_sub(char *line)
entry = VECTOR_INDEX(cmd->u.children, i);
if (entry->type == CPET_FUNCTION) {
tok = strtok(NULL, "");
+ if (tok != NULL) {
+ while (tok[0] == ' ')
+ tok++;
+ if (tok[0] == '\0')
+ tok = NULL;
+ }
entry->u.func(tok);
return;
}