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
}
....
this will call null pointer dereference.
In the
declareVariable()