Skip to content

Fixed memory leak when re-assigning w_border_highlight - #5203

Closed
dpelle wants to merge 1 commit into
vim:masterfrom
dpelle:fix-leak-w_border_highlight
Closed

Fixed memory leak when re-assigning w_border_highlight#5203
dpelle wants to merge 1 commit into
vim:masterfrom
dpelle:fix-leak-w_border_highlight

Conversation

@dpelle

@dpelle dpelle commented Nov 10, 2019

Copy link
Copy Markdown
Member

This PR fixes a memory leak detected when running make test_popwin with valgrind:

==7403== 22 bytes in 4 blocks are definitely lost in loss record 29 of 140
==7403==    at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7403==    by 0x51AEE6: lalloc (misc2.c:926)
==7403==    by 0x51AE89: alloc (misc2.c:829)
==7403==    by 0x51B5E5: vim_strsave (misc2.c:1278)
==7403==    by 0x57594E: apply_general_options (popupwin.c:758)
==7403==    by 0x57533A: f_popup_setoptions (popupwin.c:2515)
==7403==    by 0x467F90: call_internal_func (evalfunc.c:968)
==7403==    by 0x6564BA: call_func (userfunc.c:1665)
==7403==    by 0x655C62: get_func_tv (userfunc.c:482)
==7403==    by 0x65C460: ex_call (userfunc.c:3175)
==7403==    by 0x494EA1: do_one_cmd (ex_docmd.c:2482)
==7403==    by 0x491DED: do_cmdline (ex_docmd.c:975)
==7403==    by 0x65808A: call_user_func (userfunc.c:1054)
==7403==    by 0x6563F1: call_func (userfunc.c:1637)
==7403==    by 0x655C62: get_func_tv (userfunc.c:482)
==7403==    by 0x65C460: ex_call (userfunc.c:3175)
==7403==    by 0x494EA1: do_one_cmd (ex_docmd.c:2482)
==7403==    by 0x491DED: do_cmdline (ex_docmd.c:975)
==7403==    by 0x46287C: ex_execute (eval.c:6083)
==7403==    by 0x494EA1: do_one_cmd (ex_docmd.c:2482)
==7403==    by 0x491DED: do_cmdline (ex_docmd.c:975)
==7403==    by 0x65808A: call_user_func (userfunc.c:1054)
==7403==    by 0x6563F1: call_func (userfunc.c:1637)
==7403==    by 0x655C62: get_func_tv (userfunc.c:482)
==7403==    by 0x65C460: ex_call (userfunc.c:3175)
==7403==    by 0x494EA1: do_one_cmd (ex_docmd.c:2482)
==7403==    by 0x491DED: do_cmdline (ex_docmd.c:975)
==7403==    by 0x5C5142: do_source (scriptfile.c:1214)
==7403==    by 0x5C4686: cmd_source (scriptfile.c:805)
==7403==    by 0x5C459B: ex_source (scriptfile.c:831)
==7403==    by 0x494EA1: do_one_cmd (ex_docmd.c:2482)
==7403==    by 0x491DED: do_cmdline (ex_docmd.c:975)
==7403==    by 0x492BD5: do_cmdline_cmd (ex_docmd.c:587)
==7403==    by 0x6AF7AC: exe_commands (main.c:3130)
==7403==    by 0x6AE72C: vim_main2 (main.c:795)

@codecov-io

codecov-io commented Nov 10, 2019

Copy link
Copy Markdown

Codecov Report

Merging #5203 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5203      +/-   ##
==========================================
- Coverage   82.06%   82.03%   -0.03%     
==========================================
  Files         134      134              
  Lines      147272   147274       +2     
==========================================
- Hits       120855   120813      -42     
- Misses      26417    26461      +44
Impacted Files Coverage Δ
src/popupwin.c 94.5% <100%> (ø) ⬆️
src/ui.c 70.14% <0%> (-1.26%) ⬇️
src/gui.c 63.79% <0%> (-0.62%) ⬇️
src/gui_gtk_x11.c 58.11% <0%> (-0.35%) ⬇️
src/sign.c 94.41% <0%> (-0.19%) ⬇️
src/window.c 88.23% <0%> (-0.18%) ⬇️
src/drawline.c 85.37% <0%> (-0.14%) ⬇️
src/os_unix.c 63.45% <0%> (-0.05%) ⬇️
src/terminal.c 81.69% <0%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 439b3ac...2330a14. Read the comment docs.

@brammool brammool closed this in 622b646 Nov 10, 2019
manuelschiller pushed a commit to manuelschiller/vim that referenced this pull request Nov 10, 2019
Problem:    Using border highlight in popup window leaks memory.
Solution:   Free memory before overwriting. (Dominique Pelle, closes vim#5203)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants