-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
[RDY] Coverity fix resource leaks 1b #804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/// @param name The name of the register | ||
/// @param str The contents to write | ||
/// @param len If >= 0, write `len` bytes of `str`. Otherwise, write | ||
/// `strlen(str)` bytes. If `maxlen` is larger than the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another maxlen
-> len
replacement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is getting ridiculous. I'll wait a few minutes to see if you pick out another stupid omission I made.
Also constified the arguments. The double casts for the `xstrdup` are ugly but `vim_strsave` doesn't take `const` arguments for now so I couldn't keep that.
Coverity detected a memory leak caused by not free'ing the value returned by get_expr_line_src (basically vim_strsave(expr_line)). Replaced the copying with direct manipulation of expr_line, since that also happens in other parts of the codebase. NOTE: I'm aware that this has different behaviour than vim_strnsave, namely vim_strnsave always allocates `len` bytes, even if the string is shorter. I don't see how that behaviour is helpful here though.
Also cleaned up the function a little bit.
It was a false positive, but it can't hurt to "fix" it. Original warning: CID 13685 (#1 of 1): Buffer not null terminated (BUFFER_SIZE) 6. buffer_size: Calling strncpy with a source string whose length (4 chars) is greater than or equal to the size argument (4) will fail to null-terminate b0p->b0_version.
@Hinidu decided to rebase, fixed the |
@aktau 👍 :-) |
Merged! |
Because github is messing up and doesn't seem to even refer to travis anymore on PR #790, I've cherry-picked the relevant commits and posted them here.