[vim/vim] u_read_undo() leaks the file name when the undo file owner differs (PR #20987)

Samuel Schlesinger (Vim Github Repository) <[email protected]> Sun, 09 Aug 2026 13:57:06 -0700
Newsgroups gmane.editors.vim.devel
Message-ID <vim/vim/pull/[email protected]>
## Problem

When the owner of an undo file differs from the owner of the text file and
the current user, u_read_undo() returns without freeing the file name it
allocated with u_get_undo_file_name().  Every other exit frees it under
the "theend" label; this early return sits before the file pointer is
initialized, so it cannot use that label.

## Solution

Free the file name before returning.

Noticed while reworking #20942; independent of that change, so sent
separately.

AI assistance is acknowledged with Co-Authored-By trailers on the commit,
per AGENTS.md.

You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/20987

-- Commit Summary --

  * u_read_undo() leaks the file name when the undo file owner differs

-- File Changes --

    M src/undo.c (1)

-- Patch Links --

https://github.com/vim/vim/pull/20987.patch
https://github.com/vim/vim/pull/20987.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/pull/20987
You are receiving this because you are subscribed to this thread.

Message ID: <vim/vim/pull/[email protected]>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/vim/vim/pull/20987%40github.com.