Repository.CreateBlobFromBuffer panics on empty buffer #106

Closed
opened 2014-08-10 22:36:31 -05:00 by shykes · 3 comments
shykes commented 2014-08-10 22:36:31 -05:00 (Migrated from github.com)

Hi, when I call Repository.CreateBlobFromBuffer with an empty buffer as argument, I get the following trace:

panic: runtime error: index out of range [recovered]
    panic: runtime error: index out of range

goroutine 6 [running]:
runtime.panic(0x5e8620, 0x9bc217)
    /usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
testing.func·005()
    /usr/local/go/src/pkg/testing/testing.go:385 +0xe8
runtime.panic(0x5e8620, 0x9bc217)
    /usr/local/go/src/pkg/runtime/panic.c:248 +0x106
github.com/libgit2/git2go.(*Repository).CreateBlobFromBuffer(0xc2100002b0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/dev/go/src/github.com/libgit2/git2go/blob.go:40 +0x132
[...]

I'm building from ce7a12da68

Hi, when I call `Repository.CreateBlobFromBuffer` with an empty buffer as argument, I get the following trace: ``` panic: runtime error: index out of range [recovered] panic: runtime error: index out of range goroutine 6 [running]: runtime.panic(0x5e8620, 0x9bc217) /usr/local/go/src/pkg/runtime/panic.c:266 +0xb6 testing.func·005() /usr/local/go/src/pkg/testing/testing.go:385 +0xe8 runtime.panic(0x5e8620, 0x9bc217) /usr/local/go/src/pkg/runtime/panic.c:248 +0x106 github.com/libgit2/git2go.(*Repository).CreateBlobFromBuffer(0xc2100002b0, 0x0, 0x0, 0x0, 0x0, ...) /home/dev/go/src/github.com/libgit2/git2go/blob.go:40 +0x132 [...] ``` I'm building from ce7a12da68d0c4041b673593212e086865772daa
shykes commented 2014-08-10 22:38:41 -05:00 (Migrated from github.com)

Just updated to 213a1bc876 , the problem is still there.

Just updated to 213a1bc8765c93d4718cc3cdf5b08bbc969442c6 , the problem is still there.
kron4eg commented 2014-08-12 07:10:07 -05:00 (Migrated from github.com)
    ecode := C.git_blob_create_frombuffer(&oid, repo.ptr, unsafe.Pointer(&data[0]), C.size_t(len(data)))

Sorry for being obvious data is empty here...

``` ecode := C.git_blob_create_frombuffer(&oid, repo.ptr, unsafe.Pointer(&data[0]), C.size_t(len(data))) ``` Sorry for being obvious `data` is empty here...
carlosmn commented 2014-08-25 08:33:25 -05:00 (Migrated from github.com)

It looks like we go won't let us access the zeroth element of an empty slice... time for an if I suppose.

It looks like we go won't let us access the zeroth element of an empty slice... time for an `if` I suppose.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: jcarr/git2go#106
No description provided.