Hi Bram!
On Mi, 28 Nov 2012, Bram Moolenaar wrote:
>
> Christian Brabandt wrote:
>
> > On Wed, November 28, 2012 15:25, Bram Moolenaar wrote:
> > >
> > > Patch 7.3.730
> > > Problem: Crash in PHP file when using syntastic. (Ike Devolder)
> > > Solution: Avoid using NULL pointer. (Christian Brabandt)
> > > Files: src/quickfix.c
> >
> > Huh, that was fast.
>
> Trying to catch up with the long list of patches.
>
> > I haven't gotten the time to check the valgrind
> > question yet, that came up in that thread (I don't particular know
> > valgrind very well) and additionally, we should remove the win_T
> > argument to the call of qf_new_list() that was introduced with patch
> > 7.3.715.
>
> I can sort of see why setting w_llist to NULL can be removed. But
> checking with valgrind is still a good idea. If you have some script
> that will touch the relevant code.
Got some more memory leaks. Root cause is, qf_title can be NULL and will
be when using setloclist() and a like. So the memory leak prevents a
crash, which is good, but we are still leaking memory ;(
I know why it crashes, but I am not sure, what causes it. I think Vim
gets confused by the vimgrep and the setloclist() function both filling
the quickfix list and so somehow the qf_count gets invalid or does not
get reset correctly somewhere, so the following patch works around this
issue by making sure, we are only freeing valid qfline_T items.
The patch to prevent the crash and the memory leak is something like
this:
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -16292,7 +16292,8 @@
action = *act;
}
- if (l != NULL && set_errorlist(wp, l, action, NULL) == OK)
+ if (l != NULL && set_errorlist(wp, l, action, (char_u *) (wp == NULL ?
+ "setqflist()" : "setloclist()")) == OK)
rettv->vval.v_number = 0;
}
#endif
diff --git a/src/quickfix.c b/src/quickfix.c
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2124,15 +2124,19 @@
int idx;
{
qfline_T *qfp;
+ int stop = FALSE;
while (qi->qf_lists[idx].qf_count)
{
qfp = qi->qf_lists[idx].qf_start->qf_next;
- if (qi->qf_lists[idx].qf_title != NULL)
+ if (qi->qf_lists[idx].qf_title != NULL && !stop)
{
vim_free(qi->qf_lists[idx].qf_start->qf_text);
vim_free(qi->qf_lists[idx].qf_start->qf_pattern);
+ stop = (qi->qf_lists[idx].qf_start == qfp);
vim_free(qi->qf_lists[idx].qf_start);
+ if (stop)
+ qi->qf_lists[idx].qf_count = 1;
}
qi->qf_lists[idx].qf_start = qfp;
--qi->qf_lists[idx].qf_count;
Running Vim with this patch, prevents the syntastic crash and the
setloclist() crash on BufUnload and also it passes all tests and
valgrind did not complain about memory leaks anymore (at least not in
quickfix.c, but it still complains about a memory leakage in getpwuid())
regards,
Christian
--
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