Skip to content
New issue

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

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

Already on GitHub? # to your account

Binary add segfaults when at least 1 arg is non-numeric, and both are non-pointer types #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

StrongerXi
Copy link

Problem

The following program segfaults in new_add function from parse.c

void foo() { }

void bar() {
  1 + foo();
}

Proposal

Check for the case when both args are non-pointer types; check NULL explicitly to improve readability.

Note the following program still compiles with or without this patch:

void foo() { }

void bar() {
  int *a;
  a + foo();
}

It could be fixed easily, but like mentioned in #41, a separate "typecheck" phase would probably be a better solution IMHO.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant