From 66210042892389d36e3d37203ec77f61467bfb1c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 15 Apr 2016 20:40:41 +0200 Subject: [PATCH 1/4] patch 7.4.1744 Problem: Python: Converting a sequence may leak memory. Solution: Decrement a reference. (Nikolay Pavlov) --- src/if_py_both.h | 5 +++-- src/version.c | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/if_py_both.h b/src/if_py_both.h index 0b701ae082..c6a8c44635 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -6070,7 +6070,7 @@ ConvertFromPyMapping(PyObject *obj, typval_T *tv) ConvertFromPySequence(PyObject *obj, typval_T *tv) { PyObject *lookup_dict; - int ret = 0; + int ret; if (!(lookup_dict = PyDict_New())) return -1; @@ -6080,9 +6080,10 @@ ConvertFromPySequence(PyObject *obj, typval_T *tv) tv->v_type = VAR_LIST; tv->vval.v_list = (((ListObject *)(obj))->list); ++tv->vval.v_list->lv_refcount; + ret = 0; } else if (PyIter_Check(obj) || PySequence_Check(obj)) - return convert_dl(obj, tv, pyseq_to_tv, lookup_dict); + ret = convert_dl(obj, tv, pyseq_to_tv, lookup_dict); else { PyErr_FORMAT(PyExc_TypeError, diff --git a/src/version.c b/src/version.c index aa181fb22c..1dd7d49859 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1744, /**/ 1743, /**/ From 5d98c9d93278d6961bfee59151666b8a8bcd23c3 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 15 Apr 2016 20:54:52 +0200 Subject: [PATCH 2/4] patch 7.4.1745 Problem: README file is not clear about where to get Vim. Solution: Add links to github, releases and the Windows installer. (Suggested by Christian Brabandt) --- README.md | 7 +++++++ README.txt | 6 ++++++ src/version.c | 2 ++ 3 files changed, 15 insertions(+) diff --git a/README.md b/README.md index d368a75079..9be068ea98 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,13 @@ Which one you need depends on the system you want to run it on and whether you want or must compile it yourself. Check http://www.vim.org/download.php for an overview of currently available distributions. +Some popular places to get the latest Vim: +* Check out the git repository from [github](https://github.com/vim/vim). +* Get the source code as an [archive](https://github.com/vim/vim/releases). +* Get a Windows executable from the +[vim-win32-installer](https://github.com/vim/vim-win32-installer/releases) repository. + + ## Compiling ## diff --git a/README.txt b/README.txt index 0d0905aece..a47b004e06 100644 --- a/README.txt +++ b/README.txt @@ -36,6 +36,12 @@ Which one you need depends on the system you want to run it on and whether you want or must compile it yourself. Check "http://www.vim.org/download.php" for an overview of currently available distributions. +Some popular places to get the latest Vim: +* Check out the git repository from github: https://github.com/vim/vim. +* Get the source code as an archive: https://github.com/vim/vim/releases. +* Get a Windows executable from the vim-win32-installer repository: + https://github.com/vim/vim-win32-installer/releases. + COMPILING diff --git a/src/version.c b/src/version.c index 1dd7d49859..bfb64e6dee 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1745, /**/ 1744, /**/ From 95509e18f8806046eeee27482c77666bbec515da Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 15 Apr 2016 21:16:11 +0200 Subject: [PATCH 3/4] patch 7.4.1746 Problem: Memory leak in Perl. Solution: Decrement the reference count. Add a test. (Damien) --- src/if_perl.xs | 1 + src/testdir/test_perl.vim | 28 +++++++++++++++++++++++----- src/version.c | 2 ++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/if_perl.xs b/src/if_perl.xs index b091bf7cab..23246a57b1 100644 --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -844,6 +844,7 @@ I32 cur_val(IV iv, SV *sv) else rv = newBUFrv(newSV(0), curbuf); sv_setsv(sv, rv); + SvREFCNT_dec(SvRV(rv)); return 0; } #endif /* !PROTO */ diff --git a/src/testdir/test_perl.vim b/src/testdir/test_perl.vim index b523805a89..da47ab153c 100644 --- a/src/testdir/test_perl.vim +++ b/src/testdir/test_perl.vim @@ -34,7 +34,7 @@ fu catch_peval(expr) endtry call assert_true(0, 'no exception for `perleval("'.a:expr.'")`') return '' -endf +endfunc function Test_perleval() call assert_false(perleval('undef')) @@ -73,7 +73,7 @@ function Test_perleval() call assert_equal('*VIM', perleval('"*VIM"')) call assert_true(perleval('\\0') =~ 'SCALAR(0x\x\+)') -endf +endfunc function Test_perldo() sp __TEST__ @@ -82,7 +82,7 @@ function Test_perldo() 1 call assert_false(search('\Cperl')) bw! -endf +endfunc function Test_VIM_package() perl VIM::DoCommand('let l:var = "foo"') @@ -91,7 +91,7 @@ function Test_VIM_package() set noet perl VIM::SetOption('et') call assert_true(&et) -endf +endfunc function Test_stdio() redir =>l:out @@ -102,4 +102,22 @@ function Test_stdio() EOF redir END call assert_equal(['&VIM::Msg', 'STDOUT', 'STDERR'], split(l:out, "\n")) -endf +endfunc + +function Test_SvREFCNT() + new t + perl <<--perl + my ($b, $w); + $b = $curbuf for 0 .. 10; + $w = $curwin for 0 .. 10; + VIM::DoCommand('bw! t'); + if (exists &Internals::SvREFCNT) { + my $cb = Internals::SvREFCNT($$b); + my $cw = Internals::SvREFCNT($$w); + VIM::Eval("assert_equal(2, $cb)"); + VIM::Eval("assert_equal(2, $cw)"); + } + VIM::Eval("assert_false($$b)"); + VIM::Eval("assert_false($$w)"); +--perl +endfunc diff --git a/src/version.c b/src/version.c index bfb64e6dee..74e5f92359 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1746, /**/ 1745, /**/ From fe4b18640656ddea41f60cf7a76956c9cc5494d6 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 15 Apr 2016 21:47:54 +0200 Subject: [PATCH 4/4] patch 7.4.1747 Problem: Coverity: missing check for NULL pointer. Solution: Check for out of memory. --- src/if_py_both.h | 7 +++++++ src/version.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/if_py_both.h b/src/if_py_both.h index c6a8c44635..de3e8680b5 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -2922,6 +2922,13 @@ FunctionConstructor(PyTypeObject *subtype, PyObject *args, PyObject *kwargs) if (argc != 0) { argv = PyMem_New(typval_T, (size_t) argc); + if (argv == NULL) + { + PyErr_NoMemory(); + dict_unref(selfdict); + list_unref(argslist); + return NULL; + } curtv = argv; for (li = argslist->lv_first; li != NULL; li = li->li_next) copy_tv(&li->li_tv, curtv++); diff --git a/src/version.c b/src/version.c index 74e5f92359..d7544b8300 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1747, /**/ 1746, /**/