mirror of
https://github.com/Tha14/toxic.git
synced 2024-12-23 11:43:24 +01:00
another UB fix
This commit is contained in:
parent
ce4f293574
commit
83f0720a39
@ -177,7 +177,7 @@ static void groupchat_onGroupAction(ToxWindow *self, Tox *m, int groupnum, int p
|
||||
uint16_t n_len = tox_get_self_name(m, (uint8_t *) selfnick);
|
||||
selfnick[n_len] = '\0';
|
||||
|
||||
bool nick_match = strcasestr(action, selfnick);
|
||||
const char *nick_match = strcasestr(action, selfnick);
|
||||
|
||||
if (nick_match) {
|
||||
alert_type = WINDOW_ALERT_0;
|
||||
|
@ -247,4 +247,4 @@ int char_find(int idx, const char *s, char ch)
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -234,18 +234,23 @@ int complete_line(ChatContext *ctx, const void *list, int n_items, int size)
|
||||
char tmp[MAX_STR_SIZE];
|
||||
snprintf(tmp, sizeof(tmp), "%s", ubuf);
|
||||
tmp[ctx->pos] = '\0';
|
||||
char *sub = strrchr(tmp, ' ');
|
||||
const char *s = strrchr(tmp, ' ');
|
||||
char *sub = malloc(strlen(ubuf) + 1);
|
||||
int n_endchrs = 1; /* 1 = append space to end of match, 2 = append ": " */
|
||||
|
||||
if (!sub++) {
|
||||
sub = tmp;
|
||||
if (!s) {
|
||||
strcpy(sub, tmp);
|
||||
|
||||
if (sub[0] != '/') /* make sure it's not a command */
|
||||
n_endchrs = 2;
|
||||
} else {
|
||||
strcpy(sub, &s[1]);
|
||||
}
|
||||
|
||||
if (string_is_empty(sub))
|
||||
if (string_is_empty(sub)) {
|
||||
free(sub);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int s_len = strlen(sub);
|
||||
const char *match;
|
||||
@ -260,6 +265,8 @@ int complete_line(ChatContext *ctx, const void *list, int n_items, int size)
|
||||
break;
|
||||
}
|
||||
|
||||
free(sub);
|
||||
|
||||
if (!is_match)
|
||||
return -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user