diff --git a/include/cppgit2/diff.hpp b/include/cppgit2/diff.hpp index 16bac9d..0dabe9b 100644 --- a/include/cppgit2/diff.hpp +++ b/include/cppgit2/diff.hpp @@ -611,7 +611,7 @@ class diff : public libgit2_api { // the delta. class hunk : public libgit2_api { public: - hunk(const git_diff_hunk *c_ptr) : c_struct_(*c_ptr) {} + hunk(const git_diff_hunk *c_ptr) : c_struct_(c_ptr ? *c_ptr : git_diff_hunk{0}) {} // Starting line number in old_file int old_start() const { return c_struct_.old_start; } @@ -898,4 +898,4 @@ ENABLE_BITMASK_OPERATORS(diff::stats::format); ENABLE_BITMASK_OPERATORS(diff::format_email_flag); ENABLE_BITMASK_OPERATORS(diff::find_flag); -} // namespace cppgit2 \ No newline at end of file +} // namespace cppgit2