Merge "Fix potential NULL dereference errors."