mirror of
https://github.com/vim/vim.git
synced 2026-05-28 00:21:37 +02:00
patch 9.1.1943: Memory leak with :breakadd expr
Problem: Memory leak with :breakadd expr
Solution: Free debug_oldval and debug_newval before assigning to them.
Verify the existing (though confusing) :breakadd expr behavior
(zeertzjq).
It seems that :breakadd expr doesn't work as documented at all. This PR
only fixes the memory leak. The tests are for the existing behavior.
closes: #18844
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
cce452f52d
commit
a474de64df
@@ -1111,8 +1111,10 @@ debuggy_find(
|
||||
{
|
||||
if (bp->dbg_val == NULL)
|
||||
{
|
||||
vim_free(debug_oldval);
|
||||
debug_oldval = typval_tostring(NULL, TRUE);
|
||||
bp->dbg_val = tv;
|
||||
vim_free(debug_newval);
|
||||
debug_newval = typval_tostring(bp->dbg_val, TRUE);
|
||||
line = TRUE;
|
||||
}
|
||||
@@ -1129,10 +1131,12 @@ debuggy_find(
|
||||
typval_T *v;
|
||||
|
||||
line = TRUE;
|
||||
vim_free(debug_oldval);
|
||||
debug_oldval = typval_tostring(bp->dbg_val, TRUE);
|
||||
// Need to evaluate again, typval_compare() overwrites
|
||||
// "tv".
|
||||
v = eval_expr_no_emsg(bp);
|
||||
vim_free(debug_newval);
|
||||
debug_newval = typval_tostring(v, TRUE);
|
||||
free_tv(bp->dbg_val);
|
||||
bp->dbg_val = v;
|
||||
@@ -1142,7 +1146,9 @@ debuggy_find(
|
||||
}
|
||||
else if (bp->dbg_val != NULL)
|
||||
{
|
||||
vim_free(debug_oldval);
|
||||
debug_oldval = typval_tostring(bp->dbg_val, TRUE);
|
||||
vim_free(debug_newval);
|
||||
debug_newval = typval_tostring(NULL, TRUE);
|
||||
free_tv(bp->dbg_val);
|
||||
bp->dbg_val = NULL;
|
||||
|
||||
Reference in New Issue
Block a user