Skip to content

False input will cause Null pointer dereference #7

Description

@Yvan-xy
$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
  }
....

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions