Fix issues with handling invalid regex in syntax files#2913
Merged
zyedidia merged 2 commits intomicro-editor:masterfrom Sep 10, 2023
Merged
Conversation
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.
JoeKar
approved these changes
Sep 9, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
filenameorheaderfilenameregex is invalid but theheaderregex is correct