summaryrefslogtreecommitdiff
path: root/git.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2013-03-08 16:03:49 +0100
committerCarlos Martín Nieto <[email protected]>2013-03-08 16:03:49 +0100
commit62a16395b17460887747602a4184372a0c9a6d6f (patch)
tree372d9bd2553d0b84366d74e3eb9232f649b534d0 /git.go
parentb57c792bf35630ba4f73388be28966ebac404432 (diff)
Oid: make sure not to dereference a NULL git_oid
Some calls like Reference.Target() can return NULL if the reference is symbolic. Make sure newOidFromC() can handle these situations.
Diffstat (limited to 'git.go')
-rw-r--r--git.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/git.go b/git.go
index 84716e3..68712d4 100644
--- a/git.go
+++ b/git.go
@@ -26,6 +26,10 @@ type Oid struct {
}
func newOidFromC(coid *C.git_oid) *Oid {
+ if coid == nil {
+ return nil
+ }
+
oid := new(Oid)
copy(oid.bytes[0:20], C.GoBytes(unsafe.Pointer(coid), 20))
return oid