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
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Adds debug asserts that a potential NRE condition found COverity does…
… not happen.
  • Loading branch information
J Wyman committed Jul 8, 2015
commit 8909b99bd58610f6b45f090f8731ee565a39c571
6 changes: 6 additions & 0 deletions LibGit2Sharp/RepositoryStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ internal RepositoryStatus(Repository repo, StatusOptions options)
deltaIndexToWorkDir = entry.IndexToWorkDirPtr.MarshalAs<GitDiffDelta>();
}

Debug.Assert(deltaHeadToIndex != null || deltaIndexToWorkDir != null);

AddStatusEntryForDelta(entry.Status, deltaHeadToIndex, deltaIndexToWorkDir);
}

Expand Down Expand Up @@ -151,6 +153,8 @@ private void AddStatusEntryForDelta(FileStatus gitStatus, GitDiffDelta deltaHead

if ((gitStatus & FileStatus.RenamedInIndex) == FileStatus.RenamedInIndex)
{
Debug.Assert(deltaHeadToIndex != null);

headToIndexRenameDetails =
new RenameDetails(LaxFilePathMarshaler.FromNative(deltaHeadToIndex.OldFile.Path).Native,
LaxFilePathMarshaler.FromNative(deltaHeadToIndex.NewFile.Path).Native,
Expand All @@ -165,6 +169,8 @@ private void AddStatusEntryForDelta(FileStatus gitStatus, GitDiffDelta deltaHead
(int)deltaIndexToWorkDir.Similarity);
}

Debug.Assert(deltaHeadToIndex != null || deltaIndexToWorkDir != null);

var filePath = (deltaIndexToWorkDir != null)
? LaxFilePathMarshaler.FromNative(deltaIndexToWorkDir.NewFile.Path).Native
: LaxFilePathMarshaler.FromNative(deltaHeadToIndex.NewFile.Path).Native;
Expand Down
0