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

False input will cause Null pointer dereference #7

Open
Yvan-xy opened this issue Oct 14, 2020 · 0 comments
Open

False input will cause Null pointer dereference #7

Yvan-xy opened this issue Oct 14, 2020 · 0 comments

Comments

@Yvan-xy
Copy link

Yvan-xy commented Oct 14, 2020

$si:ze = 1
puts $si:ze

this will call null pointer dereference.
In the declareVariable()

  if (isalpha(tok.tok[tok.pos].val[0])) {
    tok.pos++;
    if (skip(":")) {
      if (skip("int")) {
        --tok.pos;
        return appendVar(tok.tok[npos].val, T_INT);
      }
      if (skip("string")) {
        --tok.pos;
        return appendVar(tok.tok[npos].val, T_STRING);
      }
      if (skip("double")) {
        --tok.pos;
        return appendVar(tok.tok[npos].val, T_DOUBLE);
      }
    } else {
      --tok.pos;
      return appendVar(tok.tok[npos].val, T_INT);
    }
return NULL; // return NULL 

int32_t assignment() {
  Variable *v = getVar(tok.tok[tok.pos].val);
  int32_t inc = 0, dec = 0, declare = 0;
  if (v == NULL) {
    declare++;
    v = declareVariable();   // Null
  }
....
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

1 participant