Crasher fix. Check for NULL.

Change-Id: Iae1fa695ea0266e97ae367db71fe6a82e6a3da1d