In check_for_cryptkey() located in src/fileio.c, when the encryption header is invalid (*sizep < header_len), the function returns NULL at line 3078 without freeing cryptkey:
cryptkey = crypt_get_key(newfile, FALSE); ... if (cryptkey != NULL) { int header_len; header_len = crypt_get_header_len(method); if (*sizep < header_len) // invalid header, buffer can't be encrypted return NULL; // cryptkey is leaked
When newfile is FALSE, crypt_get_key() returns a freshly allocated key (not stored in curbuf->b_p_key). On this early return, that allocation is leaked.
Free cryptkey before returning NULL when the header is invalid, but only when it's not pointing to curbuf->b_p_key. This matches the same guard used at line 3064 for the empty-key case. The fix is included in the commit.
https://github.com/vim/vim/pull/19821
(1 file)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
thanks
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()