]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0747: cscope: connection leak when growing the array fails v9.2.0747
authorChristian Brabandt <cb@256bit.org>
Sun, 28 Jun 2026 18:57:22 +0000 (18:57 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 28 Jun 2026 18:57:22 +0000 (18:57 +0000)
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 <cb@256bit.org>
src/if_cscope.c
src/version.c

index 54cae51f75d3b7641f0b40c9c3bfb7e3dcc78d19..137faed426d01674578e575d9f84d7b717f22988 100644 (file)
@@ -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)
index bb33fb77c0b4063f563185ce5536d9d2312f2664..696a78c404de1207e57e37f63cff72ccc456acbb 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    747,
 /**/
     746,
 /**/