Patch to avoid a SEGV

I found sometimes the result of SELF(self) can be NULL. So I made a patch to avoid it.
Please confirm.