Skip to content

False input will cause Null pointer dereference #7

@Yvan-xy

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
  }
....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions