Commit eafe4aef

eafe4aefa204Merged

Yasuhiro Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

analyze: cover or/and/operator writes and bounds-check class_id

Address review: extend the hash-literal reconcile to Local/Instance Or/And/Operator write nodes, and guard the ivar lookup with s->class_id < c->nclasses.

Details

Commit
eafe4aefa204
Parent
a44faa176822

src/analyze.cmodifiedView file

@@ -2341,8 +2341,14 @@
23412341 for (int id = 0; id < c->nt->count; id++) {
23422342 const char *ty = nt_type(c->nt, id);
23432343 if (!ty) continue;
2344- int is_lv = !strcmp(ty, "LocalVariableWriteNode");
2345- int is_iv = !strcmp(ty, "InstanceVariableWriteNode");
2344+ int is_lv = !strcmp(ty, "LocalVariableWriteNode") ||
2345+ !strcmp(ty, "LocalVariableOrWriteNode") ||
2346+ !strcmp(ty, "LocalVariableAndWriteNode") ||
2347+ !strcmp(ty, "LocalVariableOperatorWriteNode");
2348+ int is_iv = !strcmp(ty, "InstanceVariableWriteNode") ||
2349+ !strcmp(ty, "InstanceVariableOrWriteNode") ||
2350+ !strcmp(ty, "InstanceVariableAndWriteNode") ||
2351+ !strcmp(ty, "InstanceVariableOperatorWriteNode");
23462352 if (!is_lv && !is_iv) continue;
23472353 int v = nt_ref(c->nt, id, "value");
23482354 if (v < 0) continue;
@@ -2359,7 +2365,7 @@
23592365 if (lv) dstt = lv->type;
23602366 } else {
23612367 Scope *s = comp_scope_of(c, id);
2362- if (s && s->class_id >= 0) {
2368+ if (s && s->class_id >= 0 && s->class_id < c->nclasses) {
23632369 int iv = comp_ivar_index(&c->classes[s->class_id], nm);
23642370 if (iv >= 0) dstt = c->classes[s->class_id].ivar_types[iv];
23652371 }