Crash prevention by checking for NULL.

Change-Id: I10a0c2dcee123b884c563c3e6f83e218747e792a
Turn this into a regular method.

Change-Id: Idb4dc17971cd37a4cdf99b2c02e61fca14cb3ce2
coverity#1078504: Remove logically dead code.

Change-Id: I6bb3ee8f604d9b79209cda13a48ccd7f2df4f26e