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

Segfault when grammar entry rule doesn't exists #141

Closed
mingodad opened this issue Dec 13, 2021 · 1 comment
Closed

Segfault when grammar entry rule doesn't exists #141

mingodad opened this issue Dec 13, 2021 · 1 comment

Comments

@mingodad
Copy link
Contributor

Describe the bug
Segfault when grammar entry rule doesn't exists

To Reproduce
Steps to reproduce the behavior:

  1. Using the README json example execute peppa parse -G json.peg -e entry2 data.json
  2. See the segfault

Desktop (please complete the following information):

  • OS: linux Ubuntu 18.04 64bits

This seems to fix the problem (line numbers are from my code with other changes):

@@ -3194,9 +3330,9 @@ P4_GetErrorMessage(P4_Source* source) {
         return NULL;
 
     memset(source->errmsg, 0, sizeof(source->errmsg));
     sprintf(source->errmsg, "line %zu:%zu, expect %s",
             source->error.lineno, source->error.offset,
-            source->error.rule->name);
+            source->error.rule ? source->error.rule->name : source->entry_name);
soasme added a commit that referenced this issue Dec 13, 2021
bugfix: segfault when entry rule does not exist (#141).
@soasme soasme closed this as completed Dec 13, 2021
@soasme
Copy link
Owner

soasme commented Dec 13, 2021

Thanks for reporting the issue!

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

No branches or pull requests

2 participants