From: Christian Brabandt Date: Sun, 28 Jun 2026 18:57:22 +0000 (+0000) Subject: patch 9.2.0747: cscope: connection leak when growing the array fails X-Git-Tag: v9.2.0747^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3026d9bd8b6ecf5b7b7ad1f31abe12704da9da6;p=thirdparty%2Fvim.git 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 --- diff --git a/src/if_cscope.c b/src/if_cscope.c index 54cae51f75..137faed426 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 bb33fb77c0..696a78c404 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, /**/