Coverity flavored clang analyzer fixes#4774
Merged
Merged
Conversation
At line 594, we do this : if (error < 0) return error; but if nothing was pushed in a GIT_SORT_TIME revwalk, we'd return uninitialized stack data.
In case there was nothing to parse in the buf, we'd return uninitialized stack data.
Otherwise we'll return stack data to the caller.
Otherwise we return a NULL context, which will get dereferenced in apply_credentials.
pks-t
approved these changes
Aug 24, 2018
Member
pks-t
left a comment
There was a problem hiding this comment.
The remote initialization is not required, but that remark is too small to warrant not merging this ;)
| static int mailmap_add_buffer(git_mailmap *mm, const char *buf, size_t len) | ||
| { | ||
| int error; | ||
| int error = 0; |
Member
There was a problem hiding this comment.
Oh, yeah. In case len == 0 this can indeed be problematic
| int git_remote_lookup(git_remote **out, git_repository *repo, const char *name) | ||
| { | ||
| git_remote *remote; | ||
| git_remote *remote = NULL; |
Member
There was a problem hiding this comment.
This initialization is not necessary. All lines before remote = git__calloc(1, sizeof(git_remote)) directly return and do not touch remote.
Contributor
Author
There was a problem hiding this comment.
Sorry, I'm just going full-paranoid for future-proofing 😉.
Member
|
Oh, I forgot: thanks! :P |
Contributor
Author
|
My pleasure 😉. |
Member
|
On Fri, Aug 24, 2018 at 06:06:14AM -0700, Etienne Samson wrote:
> @@ -428,7 +428,7 @@ static int get_optional_config(
int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
{
- git_remote *remote;
+ git_remote *remote = NULL;
Sorry, I'm just going full-paranoid for future-proofing 😉.
Better safe than sorry ;) The compiler will probably optimize it
away anyway if he deems it to be unnecessary.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's that time of the year again (it's always that time).
A few potential crashers/fixes I've been sitting on, nothing really serious since we're client only but I'll defer to you on their severity.