Commit: patch 9.2.0747: cscope: connection leak when growing the array fails

0 views
Skip to first unread message

Christian Brabandt

unread,
3:00 PM (6 hours ago) 3:00 PM
to vim...@googlegroups.com
patch 9.2.0747: cscope: connection leak when growing the array fails

Commit: https://github.com/vim/vim/commit/f3026d9bd8b6ecf5b7b7ad1f31abe12704da9da6
Author: Christian Brabandt <c...@256bit.org>
Date: Sun Jun 28 18:57:22 2026 +0000

patch 9.2.0747: cscope: connection leak when growing the array fails

Problem: In cs_insert_filelist() a failed vim_realloc() when growing the
csinfo[] array frees the array and resets csinfo/csinfo_size,
discarding the still-open existing connections: their fname,
ppath and flags are leaked and the cscope child processes are
orphaned, since cs_end()/cs_reset() can no longer reach them.
(Ao Xijie)
Solution: On realloc() failure keep the original array, which is still
valid, and only fail to add the new database.

closes: #20662

Supported by AI.

Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/if_cscope.c b/src/if_cscope.c
index 54cae51f7..137faed42 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -1504,8 +1504,10 @@ cs_insert_filelist(
csinfo = vim_realloc(csinfo, sizeof(csinfo_T)*csinfo_size);
if (csinfo == NULL)
{
- vim_free(t_csinfo);
- csinfo_size = 0;
+ // allocation failure, so keep the old infos
+ csinfo = t_csinfo;
+ csinfo_size = i;
+ return -1;
}
}
if (csinfo == NULL)
diff --git a/src/version.c b/src/version.c
index bb33fb77c..696a78c40 100644
--- a/src/version.c
+++ b/src/version.c
@@ -759,6 +759,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 747,
/**/
746,
/**/
Reply all
Reply to author
Forward
0 new messages