Compare commits

...

4 Commits

Author SHA1 Message Date
Bram Moolenaar
d7a96151e0 patch 8.0.0214: leaking memory when syntax cluster id is unknown
Problem:    Leaking memory when syntax cluster id is unknown. (Coverity)
Solution:   Free the memory.
2017-01-22 15:28:55 +01:00
Bram Moolenaar
ca24e2cfcf patch 8.0.0213: Netbeans specialKeys command does not check argument length
Problem:    The Netbeans "specialKeys" command does not check if the argument
            fits in the buffer. (Coverity)
Solution:   Add a length check.
2017-01-22 15:19:22 +01:00
Bram Moolenaar
423977d3ce patch 8.0.0212: buffer for key name may be too small
Problem:    The buffer used to store a key name theoreticaly could be too
            small. (Coverity)
Solution:   Count all possible modifier characters.  Add a check for the
            length just in case.
2017-01-22 15:05:12 +01:00
Bram Moolenaar
560379d7ae patch 8.0.0211: cannot build without the multi-byte feature
Problem:    Build fails if the multi-byte feature is disabled.
Solution:   Change #ifdef around ins_char_bytes.
2017-01-21 22:50:00 +01:00
6 changed files with 38 additions and 17 deletions

View File

@@ -482,9 +482,10 @@ enum key_extra
/*
* The length of the longest special key name, including modifiers.
* Current longest is <M-C-S-T-4-MiddleRelease> (length includes '<' and '>').
* Current longest is <M-C-S-T-D-A-4-ScrollWheelRight> (length includes '<' and
* '>').
*/
#define MAX_KEY_NAME_LEN 25
#define MAX_KEY_NAME_LEN 32
/* Maximum length of a special key event as tokens. This includes modifiers.
* The longest event is something like <M-C-S-T-4-LeftDrag> which would be the

View File

@@ -2177,16 +2177,19 @@ ins_bytes_len(char_u *p, int len)
void
ins_char(int c)
{
#if defined(FEAT_MBYTE) || defined(PROTO)
char_u buf[MB_MAXBYTES + 1];
int n;
int n = 1;
#if defined(FEAT_MBYTE) || defined(PROTO)
n = (*mb_char2bytes)(c, buf);
/* When "c" is 0x100, 0x200, etc. we don't want to insert a NUL byte.
* Happens for CTRL-Vu9900. */
if (buf[0] == 0)
buf[0] = '\n';
#else
buf[0] = c;
#endif
ins_char_bytes(buf, n);
}
@@ -2195,7 +2198,6 @@ ins_char(int c)
ins_char_bytes(char_u *buf, int charlen)
{
int c = buf[0];
#endif
int newlen; /* nr of bytes inserted */
int oldlen; /* nr of bytes deleted (0 when not replacing) */
char_u *p;
@@ -2218,11 +2220,7 @@ ins_char_bytes(char_u *buf, int charlen)
/* The lengths default to the values for when not replacing. */
oldlen = 0;
#ifdef FEAT_MBYTE
newlen = charlen;
#else
newlen = 1;
#endif
if (State & REPLACE_FLAG)
{

View File

@@ -2162,6 +2162,7 @@ static struct modmasktable
/* 'A' must be the last one */
{MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'A'},
{0, 0, NUL}
/* NOTE: when adding an entry, update MAX_KEY_NAME_LEN! */
};
/*
@@ -2431,6 +2432,7 @@ static struct key_name_entry
{K_PLUG, (char_u *)"Plug"},
{K_CURSORHOLD, (char_u *)"CursorHold"},
{0, NULL}
/* NOTE: When adding a long name update MAX_KEY_NAME_LEN. */
};
#define KEY_NAMES_TABLE_LEN (sizeof(key_names_table) / sizeof(struct key_name_entry))
@@ -2658,9 +2660,14 @@ get_special_key_name(int c, int modifiers)
}
}
else /* use name of special key */
{
size_t len = STRLEN(key_names_table[table_idx].name);
if (len + idx + 2 <= MAX_KEY_NAME_LEN)
{
STRCPY(string + idx, key_names_table[table_idx].name);
idx = (int)STRLEN(string);
idx += (int)len;
}
}
string[idx++] = '>';
string[idx] = NUL;

View File

@@ -2332,7 +2332,8 @@ special_keys(char_u *args)
char *save_str = nb_unquote(args, NULL);
char *tok = strtok(save_str, " ");
char *sep;
char keybuf[64];
#define KEYBUFLEN 64
char keybuf[KEYBUFLEN];
char cmdbuf[256];
while (tok != NULL)
@@ -2359,10 +2360,13 @@ special_keys(char_u *args)
tok++;
}
if (strlen(tok) + i < KEYBUFLEN)
{
strcpy(&keybuf[i], tok);
vim_snprintf(cmdbuf, sizeof(cmdbuf),
"<silent><%s> :nbkey %s<CR>", keybuf, keybuf);
do_map(0, (char_u *)cmdbuf, NORMAL, FALSE);
}
tok = strtok(NULL, " ");
}
vim_free(save_str);

View File

@@ -5668,6 +5668,8 @@ syn_cmd_cluster(exarg_T *eap, int syncing UNUSED)
if (scl_id >= 0)
syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list,
&clstr_list, list_op);
else
vim_free(clstr_list);
got_clstr = TRUE;
}
@@ -6034,7 +6036,8 @@ get_id_list(
}
if (count != 0)
{
EMSG2(_("E408: %s must be first in contains list"), name + 1);
EMSG2(_("E408: %s must be first in contains list"),
name + 1);
failed = TRUE;
vim_free(name);
break;

View File

@@ -764,6 +764,14 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
214,
/**/
213,
/**/
212,
/**/
211,
/**/
210,
/**/