patch 9.2.0242: memory leak in check_for_cryptkey()

Problem:  memory leak in check_for_cryptkey()
Solution: Free cryptkey if it had been allocated
          (Huihui Huang)

closes: #19821

Signed-off-by: Huihui Huang <625173@qq.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Huihui Huang
2026-03-25 19:11:13 +00:00
committed by Christian Brabandt
parent 742e8722b3
commit a4c0119786
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -3074,8 +3074,12 @@ check_for_cryptkey(
header_len = crypt_get_header_len(method);
if (*sizep < header_len)
{
// invalid header, buffer can't be encrypted
if (cryptkey != curbuf->b_p_key)
vim_free(cryptkey);
return NULL;
}
curbuf->b_cryptstate = crypt_create_from_header(
method, cryptkey, ptr);
+2
View File
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
242,
/**/
241,
/**/