-
Notifications
You must be signed in to change notification settings - Fork 121
panic in wkt.Unmarshal #110
Copy link
Copy link
Closed
Description
Hello! I found a panic in the wkt.Unmarshal function.
Problem
Panic occurs when using the wkt.Unmarshal function from orb/encoding/wkt package.
How to reproduce
package main
import (
"fmt"
"os"
"github.com/paulmach/orb/encoding/wkt"
)
func main() {
input := "LINESTRING"
geom, err := wkt.Unmarshal(input)
if err != nil {
fmt.Printf("can't unmarshal: %v\n", err)
os.Exit(0)
}
fmt.Printf("unmarshaled geom: %v\n", geom)
}Expected behavior
I expect to get something like an invalid format error, or at least a panic with a message, like:
can't unmarshal: incorrect WKT format
Current behavior
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
github.com/paulmach/orb/encoding/wkt.trimSpaceBrackets({0x0?, 0xa?})
/home/kirill/go/pkg/mod/github.com/paulmach/[email protected]/encoding/wkt/unmarshal.go:125 +0x9c
github.com/paulmach/orb/encoding/wkt.Unmarshal({0x4a26bf?, 0x53a780?})
/home/kirill/go/pkg/mod/github.com/paulmach/[email protected]/encoding/wkt/unmarshal.go:256 +0x4df
main.main()
/home/kirill/go/src/github.com/sosiska/wkt/main.go:12 +0x29
Process finished with the exit code 2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels