Skip to content

Fix issues with handling invalid regex in syntax files#2913

Merged
zyedidia merged 2 commits intomicro-editor:masterfrom
dmaluka:syntax-files-invalid-regex-handling-fixes
Sep 10, 2023
Merged

Fix issues with handling invalid regex in syntax files#2913
zyedidia merged 2 commits intomicro-editor:masterfrom
dmaluka:syntax-files-invalid-regex-handling-fixes

Conversation

@dmaluka
Copy link
Collaborator

@dmaluka dmaluka commented Sep 9, 2023

  • Fix panic when a user's custom syntax file has an invalid regex for filename or header
  • Fix ignoring error when the filename regex is invalid but the header regex is correct

When a user's custom syntax file has a malformed filename regex or
header regex, MakeHeaderYaml() returns error but we do not properly
handle it, which results in a panic due to a dereference of the `header`
pointer which is nil:

Micro encountered an error: runtime.errorString runtime error: invalid memory address or nil pointer dereference
runtime/panic.go:221 (0x44c367)
runtime/panic.go:220 (0x44c337)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:709 (0x82bc0f)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:392 (0x828292)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:261 (0x8278c8)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:203 (0x8b9e7b)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:331 (0x8ba9e5)
runtime/proc.go:255 (0x4386a7)
runtime/asm_amd64.s:1581 (0x467941)
When the filename regex in a syntax file is malformed but the subsequent
header regex is correct, the filename regex error gets silently ignored,
since the `err` value is overwritten by the subsequent successful header
regex result.
@zyedidia zyedidia merged commit 9fabffc into micro-editor:master Sep 10, 2023
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 this pull request may close these issues.

3 participants