This is a fix for issue 383. Whenever a slice is passed to a function and it is to be passed down to CGo, we need to give it the address of the first slice element and the length of the slice. This is done with code like
C.someFunc(unsafe.Pointer(&x[0]))
The problem with this is that the slice might be empty, thus x[0] will panic at runtime. To go around this problem I have added checks for x == nil at all places that I found where this pattern is used.
This is a fix for issue 383. Whenever a slice is passed to a function and it is to be passed down to CGo, we need to give it the address of the first slice element and the length of the slice. This is done with code like
The problem with this is that the slice might be empty, thus
x[0]
will panic at runtime. To go around this problem I have added checks forx == nil
at all places that I found where this pattern is used.