perf: Fix NULL deref in inheritance code