Dominique Pelle wrote:

> Bram Moolenaar wrote:
> 
> > Dominique Pelle wrote:
> >
> >> I built vim-7.2.181 with GTK1 GUI on Linux x86...
> >>   ./configure  --with-features=huge --enable-gui=gtk
> >> ... and I see the following errors with valgrind memory
> >> checker when navigating in the menubar or when resizing
> >> the window:
> >>
> >> ==15894== Conditional jump or move depends on uninitialised value(s)
> >> ==15894==    at 0x8131BB3: utfc_ptr2len (mbyte.c:1705)
> >> ==15894==    by 0x81D5B0C: gui_mch_draw_string (gui_gtk_x11.c:6103)
> >> ==15894==    by 0x81CC7B9: gui_outstr_nowrap (gui.c:2251)
> >> ==15894==    by 0x81CCE63: gui_screenchar (gui.c:1872)
> >> ==15894==    by 0x81CD249: gui_redraw_block (gui.c:2500)
> >> ==15894==    by 0x81CEB63: gui_redraw (gui.c:2393)
> >> ==15894==    by 0x81D9028: expose_event (gui_gtk_x11.c:652)
> >>
> >> ==16861== Conditional jump or move depends on uninitialised value(s)
> >> ==16861==    at 0x8131B4F: utfc_ptr2len (mbyte.c:1686)
> >> ==16861==    by 0x815B7FD: mch_call_shell (os_unix.c:4314)
> >> ==16861==    by 0x812AA07: call_shell (misc2.c:3058)
> >> ==16861==    by 0x807F784: ex_diffpatch (diff.c:976)
> >> ==16861==    by 0x80C9F86: do_one_cmd (ex_docmd.c:2620)
> >> ==16861==    by 0x80C8292: do_cmdline (ex_docmd.c:1096)
> >> ==16861==    by 0x81408BF: nv_colon (normal.c:5224)
> >> ==16861==    by 0x81429A7: normal_cmd (normal.c:1188)
> >> ==16861==    by 0x8101946: main_loop (main.c:1180)
> >> ==16861==    by 0x8104CEA: main (main.c:939)
> >>
> >> Attached patch fixes it.
> >
> > What do you have 'enc' set to?  GTK only works well with utf-8.  Perhaps
> > the string should have been converted to utf-8 before we get to the
> > functions you change?
> 
> :set enc?
>     encoding=utf-8
> 
> My locale was eo_XX.UTF-8 (but I just checked that error
> also happens with en_US.UTF-8 for example).
> 
> Steps to reproduce error (without my patch):
> 
> 1/ build gvim with GTK GUI:
>    $ ./configure  --with-features=huge --enable-gui=gtk
> 
> 2/ start gvim with valgrind:
>   $ valgrind vim -f -g -u NONE -U NONE 2> valgrind.log
> 
> 3/ Then resize the gvim window and observe errors
>     in valgrind.log file as soon as window is resized.

I can't reproduce it.

> I don't think that the problem happens because of a missing
> conversion to utf-8, but because the string s at gui_gtk_x11.c:6103
> is not NUL terminated (which is fine) and we thus need to make
> sure that we don't access beyond s + len by using utfc_ptr2len_len(...)
> instead of (*mb_ptr2len)(...)

I'll have a closer look later.

-- 
ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle of Camelot.
        King of all Britons, defeator of the Saxons, sovereign of all England!
   [Pause]
SOLDIER: Get away!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui