NullReference Exception when checking for Null

I am getting an NullReference Exception when I am trying to check if a GameObject is null.

public GameObject target; 
[...]
if (target != null ) doSomething();

I know that target can be null, so I am checking for null, but this check throws a NullReference Exception…

Any ideas why this is happening?

Even with a line break, the whole if statement is considered one line. The error is that the GetComponent call is returning null.