0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

updated for version 7.2.435

Problem:    Crash when using bad_char_idx uninitialized. (Patrick Texier)
Solution:   Don't use bad_char_idx, reproduce the ++bad argument from bad_char.
This commit is contained in:
Bram Moolenaar
2010-05-16 13:26:25 +02:00
parent 4137564709
commit 34b4daf2b7
3 changed files with 12 additions and 9 deletions

View File

@@ -18309,8 +18309,8 @@ set_cmdarg(eap, oldarg)
# ifdef FEAT_MBYTE # ifdef FEAT_MBYTE
if (eap->force_enc != 0) if (eap->force_enc != 0)
len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7; len += (unsigned)STRLEN(eap->cmd + eap->force_enc) + 7;
if (eap->bad_char_idx != 0) if (eap->bad_char != 0)
len += (unsigned)STRLEN(eap->cmd + eap->bad_char_idx) + 7; len += 7 + 4; /* " ++bad=" + "keep" or "drop" */
# endif # endif
newval = alloc(len + 1); newval = alloc(len + 1);
@@ -18334,9 +18334,12 @@ set_cmdarg(eap, oldarg)
if (eap->force_enc != 0) if (eap->force_enc != 0)
sprintf((char *)newval + STRLEN(newval), " ++enc=%s", sprintf((char *)newval + STRLEN(newval), " ++enc=%s",
eap->cmd + eap->force_enc); eap->cmd + eap->force_enc);
if (eap->bad_char_idx != 0) if (eap->bad_char == BAD_KEEP)
sprintf((char *)newval + STRLEN(newval), " ++bad=%s", STRCPY(newval + STRLEN(newval), " ++bad=keep");
eap->cmd + eap->bad_char_idx); else if (eap->bad_char == BAD_DROP)
STRCPY(newval + STRLEN(newval), " ++bad=drop");
else if (eap->bad_char != 0)
sprintf((char *)newval + STRLEN(newval), " ++bad=%c", eap->bad_char);
# endif # endif
vimvars[VV_CMDARG].vv_str = newval; vimvars[VV_CMDARG].vv_str = newval;
return oldval; return oldval;

View File

@@ -1152,8 +1152,7 @@ struct exarg
int force_ff; /* ++ff= argument (index in cmd[]) */ int force_ff; /* ++ff= argument (index in cmd[]) */
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
int force_enc; /* ++enc= argument (index in cmd[]) */ int force_enc; /* ++enc= argument (index in cmd[]) */
int bad_char_idx; /* ++bad= argument (index in cmd[]) */ int bad_char; /* BAD_KEEP, BAD_DROP or replacement byte */
int bad_char; /* BAD_KEEP, BAD_DROP or replacement char */
#endif #endif
#ifdef FEAT_USR_CMDS #ifdef FEAT_USR_CMDS
int useridx; /* user command index */ int useridx; /* user command index */

View File

@@ -4688,6 +4688,7 @@ getargopt(eap)
char_u *arg = eap->arg + 2; char_u *arg = eap->arg + 2;
int *pp = NULL; int *pp = NULL;
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
int bad_char_idx;
char_u *p; char_u *p;
#endif #endif
@@ -4739,7 +4740,7 @@ getargopt(eap)
else if (STRNCMP(arg, "bad", 3) == 0) else if (STRNCMP(arg, "bad", 3) == 0)
{ {
arg += 3; arg += 3;
pp = &eap->bad_char_idx; pp = &bad_char_idx;
} }
#endif #endif
@@ -4770,7 +4771,7 @@ getargopt(eap)
{ {
/* Check ++bad= argument. Must be a single-byte character, "keep" or /* Check ++bad= argument. Must be a single-byte character, "keep" or
* "drop". */ * "drop". */
p = eap->cmd + eap->bad_char_idx; p = eap->cmd + bad_char_idx;
if (STRICMP(p, "keep") == 0) if (STRICMP(p, "keep") == 0)
eap->bad_char = BAD_KEEP; eap->bad_char = BAD_KEEP;
else if (STRICMP(p, "drop") == 0) else if (STRICMP(p, "drop") == 0)