In change_indent() located in src/indent.c, when in VREPLACE mode, orig_line is allocated at line 1336 via vim_strnsave() to save the original line content:
if (State & VREPLACE_FLAG) { orig_line = vim_strnsave(ml_get_curline(), ml_get_curline_len()); orig_col = curwin->w_cursor.col; }
Later, at line 1514, new_line is allocated. If that allocation fails, the function returns immediately without freeing orig_line:
new_line = vim_strnsave(ml_get_curline(), ml_get_curline_len()); if (new_line == NULL) return; // orig_line is leaked
On the success path, orig_line is passed to ml_replace() with copy=FALSE, which consumes it (transfers ownership to the memline). But on this failure path, ownership was never transferred, so orig_line leaks.
Free orig_line before returning when new_line allocation fails. The fix is included in the commit.
https://github.com/vim/vim/pull/19820
(1 file)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
thanks, makes sense.
—
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.![]()