comparison src/ex_docmd.c @ 2169:cf8f86128f4c v7.2.435

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.
author Bram Moolenaar <bram@vim.org>
date Sun, 16 May 2010 13:26:25 +0200
parents 99b225e0dbc1
children f60a0c9cbe6c
comparison
equal deleted inserted replaced
2167:7b875bfb39b8 2169:cf8f86128f4c
4686 exarg_T *eap; 4686 exarg_T *eap;
4687 { 4687 {
4688 char_u *arg = eap->arg + 2; 4688 char_u *arg = eap->arg + 2;
4689 int *pp = NULL; 4689 int *pp = NULL;
4690 #ifdef FEAT_MBYTE 4690 #ifdef FEAT_MBYTE
4691 int bad_char_idx;
4691 char_u *p; 4692 char_u *p;
4692 #endif 4693 #endif
4693 4694
4694 /* ":edit ++[no]bin[ary] file" */ 4695 /* ":edit ++[no]bin[ary] file" */
4695 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) 4696 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0)
4737 pp = &eap->force_enc; 4738 pp = &eap->force_enc;
4738 } 4739 }
4739 else if (STRNCMP(arg, "bad", 3) == 0) 4740 else if (STRNCMP(arg, "bad", 3) == 0)
4740 { 4741 {
4741 arg += 3; 4742 arg += 3;
4742 pp = &eap->bad_char_idx; 4743 pp = &bad_char_idx;
4743 } 4744 }
4744 #endif 4745 #endif
4745 4746
4746 if (pp == NULL || *arg != '=') 4747 if (pp == NULL || *arg != '=')
4747 return FAIL; 4748 return FAIL;
4768 } 4769 }
4769 else 4770 else
4770 { 4771 {
4771 /* Check ++bad= argument. Must be a single-byte character, "keep" or 4772 /* Check ++bad= argument. Must be a single-byte character, "keep" or
4772 * "drop". */ 4773 * "drop". */
4773 p = eap->cmd + eap->bad_char_idx; 4774 p = eap->cmd + bad_char_idx;
4774 if (STRICMP(p, "keep") == 0) 4775 if (STRICMP(p, "keep") == 0)
4775 eap->bad_char = BAD_KEEP; 4776 eap->bad_char = BAD_KEEP;
4776 else if (STRICMP(p, "drop") == 0) 4777 else if (STRICMP(p, "drop") == 0)
4777 eap->bad_char = BAD_DROP; 4778 eap->bad_char = BAD_DROP;
4778 else if (MB_BYTE2LEN(*p) == 1 && p[1] == NUL) 4779 else if (MB_BYTE2LEN(*p) == 1 && p[1] == NUL)