Dominique Pelle wrote:
> Valgrind memory checker detects the following bug in
> vim-7.1 (patches 1-68) on Linux x86.
>
> ==7405== Conditional jump or move depends on uninitialised value(s)
> ==7405== at 0x8152C76: spell_move_to (spell.c:2150)
> ==7405== by 0x813DC28: win_line (screen.c:3040)
> ==7405== by 0x813BC14: win_update (screen.c:1760)
> ==7405== by 0x813A022: update_screen (screen.c:522)
> ==7405== by 0x80CD213: main_loop (main.c:1109)
> ==7405== by 0x80CCF62: main (main.c:939)
> ==7405==
> ==7405== Conditional jump or move depends on uninitialised value(s)
> ==7405== at 0x8152C8D: spell_move_to (spell.c:2157)
> ==7405== by 0x813DC28: win_line (screen.c:3040)
> ==7405== by 0x813BC14: win_update (screen.c:1760)
> ==7405== by 0x813A022: update_screen (screen.c:522)
> ==7405== by 0x80CD213: main_loop (main.c:1109)
> ==7405== by 0x80CCF62: main (main.c:939)
>
> Looking at the code, 'can_spell' variable is meant to be initialized
> at line spell.c:2148 and then used at line spell.c:2150 and
> spell.c:2157:
>
> spell.c:
> 2144 # ifdef FEAT_SYN_HL
> 2145 if (has_syntax)
> 2146 {
> 2147 col = (int)(p - buf);
> INIT 2148 (void)syn_get_id(wp, lnum, (colnr_T)col,
> 2149 FALSE, &can_spell);
> USE 2150 if (!can_spell)
> 2151 attr = HLF_COUNT;
> 2152 }
> 2153 else
> 2154 #endif
> 2155 can_spell = TRUE;
> 2156
> USE 2157 if (can_spell)
> 2158 {
>
> However, there are several paths inside syn_get_id()->get_syntax_attr()
> where 'can_spell' may not be initialized (which does happens in practice
> since valgrind detects it).
>
> Bug happens with syntax highlighting + spelling checker on a C file.
> I can reproduce it 100% of the time by doing something a bit silly
> (but that's often how we find bugs): visual select all lines of a
> C file, use J command to join all lines (then valgrind detects bug).
>
> I attach a patch which ensures default initialization of 'can_spell'
> variable.
Thanks for finding another problem and figuring out why it happens.
I think a slightly better solution is to set the default for can_spell
in get_syntax_attr(), depending on where spell checking is supposed to
happen. We can assume that when we don't find a syntax attribute that
we use do spell checking as if at the toplevel.
*** ../vim-7.1.068/src/syntax.c Thu Jul 26 22:55:11 2007
--- src/syntax.c Sun Aug 12 19:49:07 2007
***************
*** 1727,1732 ****
--- 1727,1739 ----
{
int attr = 0;
+ if (can_spell != NULL)
+ /* Default: Only do spelling when there is no @Spell cluster or when
+ * ":syn spell toplevel" was used. */
+ *can_spell = syn_buf->b_syn_spell == SYNSPL_DEFAULT
+ ? (syn_buf->b_spell_cluster_id == 0)
+ : (syn_buf->b_syn_spell == SYNSPL_TOP);
+
/* check for out of memory situation */
if (syn_buf->b_sst_array == NULL)
return 0;
--
All true wisdom is found on T-shirts.
/// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---