pointers-memory · intermediate · ~15 min
Recognise the use-after-free pattern as a state condition.
An operation trace uses 'a' (allocate), 'f' (free), 'u' (use) on a single resource. Implement int has_use_after_free(const char *ops) returning 1 if any 'u' happens while the resource is freed (and not re-allocated), else 0.
int has_use_after_free(const char *ops) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.