Don't dereference target if it is NULL.

Caught by the clang static analyzer by Jason Molenda.