Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@yegappan
Copy link
Member

@yegappan yegappan commented May 6, 2018

The qf_parse_line() function in quickfix.c is too long. Refactor the function.
Add additional comments to some of the functions. No new functionality
is introduced in this patch.

src/quickfix.c Outdated
if (linelen >= fields->errmsglen)
{
/* linelen + null terminator */
if ((fields->errmsg = vim_realloc(fields->errmsg,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way of calling realloc leaks memory if realloc(…) fails i.e. if it returns NULL.
See https://www.viva64.com/en/w/v701/ for more details.

src/quickfix.c Outdated
if (len >= fields->errmsglen)
{
/* len + null terminator */
if ((fields->errmsg = vim_realloc(fields->errmsg, len + 1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark: leak if vim_realloc(…) returns NULL.

src/quickfix.c Outdated
if (linelen >= fields->errmsglen)
{
/* linelen + null terminator */
if ((fields->errmsg = vim_realloc(fields->errmsg,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leak if vim_realloc(…) fails.

@vim-ml
Copy link

vim-ml commented May 7, 2018 via email

@codecov-io
Copy link

codecov-io commented May 7, 2018

Codecov Report

Merging #2881 into master will increase coverage by 0.02%.
The diff coverage is 88.4%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2881      +/-   ##
==========================================
+ Coverage   75.53%   75.55%   +0.02%     
==========================================
  Files          92       92              
  Lines      134866   134900      +34     
==========================================
+ Hits       101867   101930      +63     
+ Misses      32999    32970      -29
Impacted Files Coverage Δ
src/quickfix.c 93.07% <88.4%> (+0.01%) ⬆️
src/if_xcmdsrv.c 84.17% <0%> (-0.36%) ⬇️
src/ex_cmds.c 79.38% <0%> (-0.23%) ⬇️
src/ex_cmds2.c 79.1% <0%> (-0.1%) ⬇️
src/ex_docmd.c 75.95% <0%> (-0.02%) ⬇️
src/if_py_both.h 76.59% <0%> (ø) ⬆️
src/screen.c 76.59% <0%> (+0.04%) ⬆️
src/os_unix.c 54.47% <0%> (+0.04%) ⬆️
src/gui_gtk_x11.c 47.83% <0%> (+0.04%) ⬆️
src/gui.c 49.15% <0%> (+0.05%) ⬆️
... and 4 more

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 402c839...7257738. Read the comment docs.

@brammool brammool closed this in 18cebf4 May 8, 2018
adizero pushed a commit to adizero/vim that referenced this pull request May 19, 2018
Problem:    qf_parse_line() is too long.
Solution:   Split it in parts.  Properly handle vim_realloc() failing.
            (Yegappan Lakshmanan, closes vim#2881)
mhinz added a commit to mhinz/neovim that referenced this pull request Apr 3, 2019
Problem:    qf_parse_line() is too long.
Solution:   Split it in parts.  Properly handle vim_realloc() failing.
            (Yegappan Lakshmanan, closes vim/vim#2881)

vim/vim@18cebf4
mhinz added a commit to mhinz/neovim that referenced this pull request Apr 4, 2019
Problem:    qf_parse_line() is too long.
Solution:   Split it in parts.  Properly handle vim_realloc() failing.
            (Yegappan Lakshmanan, closes vim/vim#2881)

vim/vim@18cebf4
mhinz added a commit to mhinz/neovim that referenced this pull request Apr 8, 2019
Problem:    qf_parse_line() is too long.
Solution:   Split it in parts.  Properly handle vim_realloc() failing.
            (Yegappan Lakshmanan, closes vim/vim#2881)

vim/vim@18cebf4
mhinz added a commit to mhinz/neovim that referenced this pull request Apr 8, 2019
Problem:    qf_parse_line() is too long.
Solution:   Split it in parts.  Properly handle vim_realloc() failing.
            (Yegappan Lakshmanan, closes vim/vim#2881)

vim/vim@18cebf4
mhinz added a commit to mhinz/neovim that referenced this pull request Apr 19, 2019
Problem:    qf_parse_line() is too long.
Solution:   Split it in parts.  Properly handle vim_realloc() failing.
            (Yegappan Lakshmanan, closes vim/vim#2881)

vim/vim@18cebf4
mhinz added a commit to mhinz/neovim that referenced this pull request May 3, 2019
Problem:    qf_parse_line() is too long.
Solution:   Split it in parts.  Properly handle vim_realloc() failing.
            (Yegappan Lakshmanan, closes vim/vim#2881)

vim/vim@18cebf4
mhinz added a commit to mhinz/neovim that referenced this pull request May 3, 2019
Problem:    qf_parse_line() is too long.
Solution:   Split it in parts.  Properly handle vim_realloc() failing.
            (Yegappan Lakshmanan, closes vim/vim#2881)

vim/vim@18cebf4
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.

4 participants