Jesse Portnoy
|
b5b98d2281
|
In highlightEmptyRegion(), if no rules are defined, return
immediately.
The following snippet will trigger SIGSEGV otherwise:
```go
syntaxFile, _ := ioutil.ReadFile("/non/existing/path" + "yml.yaml")
syntaxDef, err := highlight.ParseDef(syntaxFile)
if err != nil {
return err
}
h := highlight.NewHighlighter(syntaxDef)
matches := h.HighlightString(string(codeBlock.Literal))
```
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x574656]
goroutine 1 [running]:
github.com/zyedidia/highlight.(*Highlighter).highlightEmptyRegion(0xc000129b98, 0xc0000db980?, 0x0, 0x1, 0x0?, {0xc0001880b0, 0x2a, 0x2c}, 0x0)
/home/jesse/go/pkg/mod/github.com/zyedidia/highlight@v0.0.0-20200217010119-291680feaca1/highlighter.go:215 +0x96
github.com/zyedidia/highlight.(*Highlighter).HighlightString(0xc000129b98, {0xc0000db980?, 0x2b?})
/home/jesse/go/pkg/mod/github.com/zyedidia/highlight@v0.0.0-20200217010119-291680feaca1/highlighter.go:278 +0x130
```
|
2023-07-16 02:17:04 +01:00 |
|