diff --git a/geom/wkb_marshal.go b/geom/wkb_marshal.go index 5881bb8c..a091a643 100644 --- a/geom/wkb_marshal.go +++ b/geom/wkb_marshal.go @@ -86,5 +86,8 @@ func (m *wkbMarshaler) writeSequence(seq Sequence) { // floatsAsBytes reinterprets the floats slice as a bytes slice in a similar // manner to reinterpret_cast in C++. func floatsAsBytes(floats []float64) []byte { + if len(floats) == 0 { + return nil + } return unsafe.Slice((*byte)(unsafe.Pointer(&floats[0])), 8*len(floats)) } diff --git a/geom/wkb_parser.go b/geom/wkb_parser.go index 751c625b..c350e916 100644 --- a/geom/wkb_parser.go +++ b/geom/wkb_parser.go @@ -223,6 +223,9 @@ func (p *wkbParser) parseLineString(ctype CoordinatesType) (LineString, error) { // bytesAsFloats reinterprets the bytes slice as a float64 slice in a similar // manner to reinterpret_cast in C++. func bytesAsFloats(byts []byte) []float64 { + if len(byts) == 0 { + return nil + } return unsafe.Slice((*float64)(unsafe.Pointer(&byts[0])), len(byts)/8) }