Strange null dereference error

With the following code: