klass might be 0 here

This was now segfaulting because RCLASS_SERIAL would dereference klass.
This didn't happen before so it was not a problem in the old
implementation from before class based serial invalidation.

Fixes https://bugs.ruby-lang.org/issues/9377