fix length segfault
This commit is contained in:
parent
79fee676a4
commit
35005081b6
1 changed files with 7 additions and 5 deletions
|
@ -61,17 +61,19 @@ int get_command(char *command, char *command_re, char **sort_tmp) {
|
||||||
if (!get_out)
|
if (!get_out)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command[0] == ';') {
|
||||||
|
command++;
|
||||||
|
}
|
||||||
|
|
||||||
int cl = strlen(command);
|
int cl = strlen(command);
|
||||||
|
|
||||||
if (cl == 0) return 0;
|
if (cl < 2) return 0;
|
||||||
|
|
||||||
command[cl - 1] = '\0';
|
command[cl - 1] = '\0';
|
||||||
|
|
||||||
for (int i = 0; i < cl - 1; i++) {
|
for (int i = 0; i < cl - 1; i++) {
|
||||||
command[i] = tolower(command[i]);
|
command[i] = tolower(command[i]);
|
||||||
if ((i == 0 || i == cl - 1) && command[i] == ';') {
|
|
||||||
command[i] = ' ';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sort_tmp[0] = command;
|
sort_tmp[0] = command;
|
||||||
|
@ -79,7 +81,7 @@ int get_command(char *command, char *command_re, char **sort_tmp) {
|
||||||
for (int i = 1; i < MAX_COMBO_LENGTH; i++) {
|
for (int i = 1; i < MAX_COMBO_LENGTH; i++) {
|
||||||
combos = i;
|
combos = i;
|
||||||
sort_tmp[i] = strstr(sort_tmp[i - 1], ";");
|
sort_tmp[i] = strstr(sort_tmp[i - 1], ";");
|
||||||
if (sort_tmp[i] == 0)
|
if (sort_tmp[i] == 0 || sort_tmp[i] == sort_tmp[i-1])
|
||||||
break;
|
break;
|
||||||
if (strlen(sort_tmp[i]) < 2) {
|
if (strlen(sort_tmp[i]) < 2) {
|
||||||
sort_tmp[i][0] = '\0';
|
sort_tmp[i][0] = '\0';
|
||||||
|
|
Loading…
Reference in a new issue