From 62a16395b17460887747602a4184372a0c9a6d6f Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Fri, 8 Mar 2013 16:03:49 +0100 Subject: 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. --- git.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'git.go') 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 -- cgit v1.2.3