8000 Fixing Coverity Defects Part Deux by whoisj · Pull Request #1130 · libgit2/libgit2sharp · GitHub
[go: up one dir, main page]

Skip to content

Fixing Coverity Defects Part Deux #1130

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

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Resolves a NRE condition defect found by Coverity by returning an err…
…or code to the callback invoker.
  • Loading branch information
J Wyman committed Jul 8, 2015
commit ad50712f2c84d745685ea06f3f2a06f646d051a3
5 changes: 5 additions & 0 deletions LibGit2Sharp/Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ private int PrintCallBack(GitDiffDelta delta, GitDiffHunk hunk, GitDiffLine line
PatchEntryChanges currentChange = this[filePath];
string prefix = string.Empty;

if (currentChange == null)
{
return (int)GitErrorCode.NotFound;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about. This will brutally flow back to libgit2.

Is there even a case when currentChange could actually be null?

Copy link
Author

Choose a reason for hiding this comment

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

Is there even a case when currentChange could actually be null?

@nulltoken Coverity sure seems to think there is. Perhaps in some kind of repo corruption case? Not sure really. Null checking doesn't seem like a bad thing. Very little overhead and it would be correct to route and error back to the base lib if the value were null.

}

switch (line.lineOrigin)
{
case GitDiffLineOrigin.GIT_DIFF_LINE_CONTEXT:
Expand Down
0