Bram Moolenaar <[email protected]> wrote:

> Patch 7.4.434
> Problem:    gettabvar() is not consistent with getwinvar() and getbufvar().
> Solution:   Return a dict with all variables when the varname is empty.
>             (Yasuhiro Matsumoto)
> Files:      src/eval.c, runtime/doc/eval.txt, src/testdir/test91.in,
>             src/testdir/test91.ok

Hi

Something is wrong with patch 7.4.434.  I get this compilation
warning with clang:

eval.c:12089:38: warning: variable 'win' is uninitialized when used
here [-Wuninitialized]
        switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE);
                                            ^~~
eval.c:12074:15: note: initialize the variable 'win' to silence this warning
    win_T       *win, *oldcurwin;
                    ^
                     = NULL

12069     static void
 12070 f_gettabvar(argvars, rettv)
 12071     typval_T    *argvars;
 12072     typval_T    *rettv;
 12073 {
!12074     win_T       *win, *oldcurwin;
 12075     tabpage_T   *tp, *oldtabpage;
 12076     dictitem_T  *v;
 12077     char_u      *varname;
 12078     int         done = FALSE;
 12079
 12080     rettv->v_type = VAR_STRING;
 12081     rettv->vval.v_string = NULL;
 12082
 12083     varname = get_tv_string_chk(&argvars[1]);
 12084     tp = find_tabpage((int)get_tv_number_chk(&argvars[0], NULL));
 12085     if (tp != NULL && varname != NULL)
 12086     {
 12087         /* Set curwin to be our win, temporarily.  Also set the tabpage,
 12088          * otherwise the window is not valid. */
!12089         switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE);

Calling switch_win(...) at line eval.c:12089 is going to set
curwin to win, which is uninitialized so it looks wrong.

Line eval.c:12089 was introduced in patch 7.4.434 today.
Is a piece of patch 7.4.434 missing?

Running tests with valgrind confirms the bug in test62:

==5760== Memcheck, a memory error detector
==5760== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==5760== Using Valgrind-3.9.0.SVN and LibVEX; rerun with -h for copyright info
==5760== Command: ../vim -u unix.vim -U NONE --noplugin -s dotest.in test62.in
==5760==
==5760== Conditional jump or move depends on uninitialised value(s)
==5760==    at 0x641B10: win_valid (window.c:1303)
==5760==    by 0x64887A: switch_win (window.c:6698)
==5760==    by 0x459AB7: f_gettabvar (eval.c:12089)
==5760==    by 0x443450: call_func (eval.c:8626)
==5760==    by 0x4461B0: get_func_tv (eval.c:8433)
==5760==    by 0x46D76D: eval7 (eval.c:5210)
==5760==    by 0x46CD3E: eval6 (eval.c:4861)
==5760==    by 0x46C897: eval5 (eval.c:4677)
==5760==    by 0x46BACA: eval4 (eval.c:4370)
==5760==    by 0x46B8B9: eval3 (eval.c:4282)
==5760==    by 0x46B6A9: eval2 (eval.c:4211)
==5760==    by 0x4420A2: eval1 (eval.c:4136)
==5760==    by 0x441C23: eval0 (eval.c:4093)
==5760==    by 0x4418DF: eval_to_bool (eval.c:1289)
==5760==    by 0x4A3E52: ex_if (ex_eval.c:923)
==5760==  Uninitialised value was created by a stack allocation
==5760==    at 0x459A20: f_gettabvar (eval.c:12073)
==5760==
==5760== Conditional jump or move depends on uninitialised value(s)
==5760==    at 0x641B44: win_valid (window.c:1306)
==5760==    by 0x64887A: switch_win (window.c:6698)
==5760==    by 0x459AB7: f_gettabvar (eval.c:12089)
==5760==    by 0x443450: call_func (eval.c:8626)
==5760==    by 0x4461B0: get_func_tv (eval.c:8433)
==5760==    by 0x46D76D: eval7 (eval.c:5210)
==5760==    by 0x46CD3E: eval6 (eval.c:4861)
==5760==    by 0x46C897: eval5 (eval.c:4677)
==5760==    by 0x46BACA: eval4 (eval.c:4370)
==5760==    by 0x46B8B9: eval3 (eval.c:4282)
==5760==    by 0x46B6A9: eval2 (eval.c:4211)
==5760==    by 0x4420A2: eval1 (eval.c:4136)
==5760==    by 0x441C23: eval0 (eval.c:4093)
==5760==    by 0x4418DF: eval_to_bool (eval.c:1289)
==5760==    by 0x4A3E52: ex_if (ex_eval.c:923)
==5760==  Uninitialised value was created by a stack allocation
==5760==    at 0x459A20: f_gettabvar (eval.c:12073)

Regards
Dominique

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui