Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic in wkt.Unmarshal #110

Closed
sosiska opened this issue Oct 18, 2022 · 0 comments · Fixed by #119
Closed

panic in wkt.Unmarshal #110

sosiska opened this issue Oct 18, 2022 · 0 comments · Fixed by #119

Comments

@sosiska
Copy link

sosiska commented Oct 18, 2022

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant